javascript - Angular ui-router controller scope -


when use regular angular controller, place controller attribute inside dom element, , controller controls dom tree inside element, e.g.

<div ng-controller="mycontroller"> 

when attach controller via ui-router in app.js file, via states config, this:

.state('report', {     url: '/site/:site/report',     templateurl: 'minderbinder/report/view/report.html',     controller: 'reportcontroller' }) 

what scope of controller?

you shouldn't declare controller manually in div, unless intent make child (controller) of reportcontroller control nested , specific part of dom.

as child, mycontroller inherit reportcontroller's scope, latter being upmost controller of template.

the benefit of avoiding declare controller in html promote reusability of html template across potential various controllers, using exact same html.

a typical example edit form , adding form (crud) mapped own distinct controllers same html template.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -