search

Home  >  Q&A  >  body text

angular.js - Why can't I directly write the name of the controller when specifying the controller in the angularjs route?

Writing like this works: controller: 'loginctrl as loginctrl'
It doesn't work when I write controller: 'loginctrl'. What's going on?

PHP中文网PHP中文网2793 days ago486

reply all(1)I'll reply

  • 阿神

    阿神2017-05-15 17:00:46

    ng1.2 introduced controllerAs, which is what you use ctrl as ctrl, mainly to avoid having to inject $scope and the lightweight controller itself.

    If you want to use the original ng-controller. You cannot use this to bind scope, and you have to manually inject $scope.

    reply
    0
  • Cancelreply