i don't know how to listen property of controller through the $scope
http://codepen.io/Tek/pen/fgIkG/ - controller as syntax
http://codepen.io/Tek/pen/zqCpF /?editors=111 - $scope
You need to use $scope
and not this
inside a controller to bind values.
Here's the edited code And I believe you were going for this .
In the newest version of Angular JS
ie, 1.2
they have introduces a new keyword controllerAs
to make it possible not to have scope inside a controller.
<div ng-controller="testCtrl as test">
{{test.value}}
</div>
And in your controller
app.controller('testCtrl ', function () {
this.value = 'Hello World';
});
See the above controller is generated with out injecting $scope
in it.
Here is a good video tutorial explaining this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.