I am wondering at the dual behaviour of $scope. In the below script I am getting value of name
as alert. But in my ionic app the same code alerts undefined
.
I googled the problem and found this link as a solution where it states that we need to use dot(.) in order to get the value in ng-model
. What is the difference between two.
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.a =function a(){alert($scope.name);}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="name" ng-blur="a()">
</div>