'this' vs $scope in AngularJS controllers

后端 未结 7 1649
逝去的感伤
逝去的感伤 2020-11-21 05:18

In the \"Create Components\" section of AngularJS\'s homepage, there is this example:

controller: function($scope, $element) {
  var panes = $scope.panes = [         


        
7条回答
  •  轮回少年
    2020-11-21 05:30

    In this course(https://www.codeschool.com/courses/shaping-up-with-angular-js) they explain how to use "this" and many other stuff.

    If you add method to the controller through "this" method, you have to call it in the view with controller's name "dot" your property or method.

    For example using your controller in the view you may have code like this:

        
    Your first pane is {{aliasOfYourController.panes[0]}}

提交回复
热议问题