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
Post a Comment