I have a form in angularjs
<form ng-submit="addNewNote(noteData)">
<button type="submit" class="md-icon-button ion-nav-button-right md-button md-default-theme" aria-label="Setting" tabindex="0">
{{noteTxt}}
</button>
<ion-content>
<div id="note-detail-content">
<md-input-container md-no-float>
<input required name="noteTitle" placeholder="Note Title (Required)" ng-model="noteData.title">
</md-input-container>
<textarea rows="7" ng-model="noteData.description" maxlength="250"
placeholder="Write something here ...."></textarea>
<span>
</span>
</div><!--end content section-->
</ion-content>
<!--end note detail section-->
</form>
The problem is ng-submit
fired two times, also noteData.title
doesn't read any value even if a value is present.
I'm getting this error
Cannot read property 'title' of undefined
I've checked this question but my code doesn't include angular twice, if it is, how can i check it?
$scope.addNewNote=function(noteData){
alert(noteData.title);
}
index.html links
<!-- Ionic javascript lib -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- end Ionic javascript lib -->
<!-- Angular javascript lib -->
<script src="lib/angular-messages.js"></script>
<script src="lib/angular-aria.js"></script>
<script src="lib/angular-material.js"></script>
<!-- end Angular javascript lib -->
<!-- Cordova script (this will be a 404 during development) -->
<script src="lib/ng-cordova.js"></script>
<script src="cordova.js"></script>
UPDATE app.js file
.state('app.addnote', {
url: "/addnote",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/note/html/note-add.html",
controller: 'AddNotesCtrl'
}
}
})
.state('app.notelist', {
url: "/notelist",
params:{
isAnimated:true
},
cache: false,
views: {
'menuContent': {
templateUrl: "templates/application-storage/local-application-db/html/note-list.html",
controller: 'noteListCtrl'
}
}
}
)
Controller.js
var appControllers = angular.module('starter.controllers', []); // Use for all controller of application.
var appServices = angular.module('starter.services', []);// Use for all service of application.
appControllers.controller('AddNotesCtrl',function($scope,$rootScope,$state,$mdToast){
}