angularjs - How can I remove the need to use $scope with ui-router and services? -


my ui-router configuration looks this:

    var homeaccess = {         name: 'home.access',         url: 'access',         templateurl: 'app/access/partials/webapi.html',         controller: [                 '$scope',                  'accessservice',                  'testservice'                function (                 $scope,                  accessservice: iaccessservice                 testservice: itestservice) {             $scope.ac = accessservice;             $scope.ts = testservice;         }]     }; 

in html use accessservice , testsaervice this:

<input ng-model="ac.statustext" /> <input ng-model="ts.text" /> 

from understand better if not use $scope. can tell me how implement without using $scope?

i don't see point unless you've got legitimate reasons avoiding $scope (see angularjs - why use "controller vm"?). being said, can use controller as expression...

controller: ['accessservice', 'testservice', function(accessservice, testservice) {     this.ac = accessservice;     this.ts = testservice; }], controlleras: 'homeaccess' // or whatever want call 

and in template

<input ng-model="homeaccess.ac.statustext"> <input ng-model="homeaccess.ts.text"> 

keep in mind still using scope binding controller instance $scope controlleras expression.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -