http://docs.angularjs.org/api/ng/directive/ngChange
"The expression is not evaluated when the value change is coming from the
model."
if you want to call change() any time the model changes, just execute a
$watch on the model.
$scope.$watch('testModel', $scope.change);
And instead of using ng-init in your template, you should be setting the
model in your controller
$scope.testModel = 'John';
On Tuesday, March 25, 2014 10:57:51 PM UTC-4, ru ga wrote:
>
> Hi all,
>
> I've built a application with AngularJs and NodeJs, view template EJS.
> When I render a page, I set value of input (ng-model) and I want to get
> that model in controller but I can't get it.
> This is my file EJS:
>
> <!DOCTYPE html>
> <html ng-app='test'>
> <head>
> <script src="/angular/angular.js"></script>
> <link rel='stylesheet' href='/stylesheets/style.css' />
> </head>
> <body ng-controller='testCtrl'>
> <input type="text" ng-model='testModel' ng-change='change()'
> ng-init="testModel ='John'">
> </body>
> </html>
>
> <script>
> var testApp = angular.module('test', []);
>
> testApp.controller('testCtrl', function($scope){
> $scope.change = function(){
> console.log($scope.testModel);
> };
> console.log($scope.testModel);
> });
> </script>
>
> Anyone can help me please?
> Thanks and Best Regards,
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.