ng-model does not affect the scope and I can't understand why.
Here is most of my HTML:
<ion-view view-title="{{ inputType | uppercase | translate }}">
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<input ng-model="amount" class="text-align-center" type="number" placeholder="{{ 'AMOUNT' | translate }}">
</label>
</div>
<button class="button button-block button-stable" ng-click="okAmount()">{{ 'SAVE' | translate }}</button>
</ion-content>
</ion-view>
Here is most of my controller:
(function(){
angular.module('mb')
.controller('EnterAmountCtrl', ['$scope', '$state', '$filter', '$translate',
function($scope, $state, $filter, $translate) {
$scope.amount = '';
$scope.okAmount = function() {
console.log($scope.amount);
};
}]);
})();
I don't think that this can be a scoping issue. There are no nested controllers. Routing is handled like this:
$stateProvider.state('enter-amount', {
url: '/enter-amount/:inputType',
templateUrl: 'templates/enter-amount.html',
controller: 'EnterAmountCtrl'
});
Regardless of what I write in the text box, $scope.amount remains undefined. What might be causing this?
ng-model="account"(where account is a primitive value), dong-model="myData.account"(wheremyDatais an object that will survive the prototypical inheritance and not create scope issues). BTW, nested controllers are not the only way to create these issues,ng-if,ng-include,ng-repeat, etc. also create new scopes.container.valueas your model on the children scopes. that way the container gets inherited through the children, and will not be room for confusion. This is the principle behind the controllerAs syntax you could benefit from