javascript - Angular Directives: scope vs bindToController -


since angular v1.4, it's possible this:

scope: {}, bindtocontroller: {     name: "=" } 

instead of old way of doing:

scope: {     name: "=" }, bindtocontroller: true 

except being more intuitive, there difference between them?

think bindtocontroller migration path future version of angular.

we prefer write directives (or components) isolated scope , bind controller properties want pass.

binding variables scope gradually disappear.

in new release of angular (1.5) don't need use scope or bindtocontroller, because scope isolated default , bind variables controller can use bindings.

this useful preventing $scope use. read article if want more info that: https://toddmotto.com/no-scope-soup-bind-to-controller-angularjs/


Comments