How To Set A Variable To Be Used Inside An Ng-include Directive

Posted by Weston Ganger on January 11, 2016

Some angular directives create a new scope such as ng-if or ng-include

If you want to set a variable inside that scope add the ng-init attribute to the element

<div ng-include="path/to/your_template.html" ng-init="my_var = 'hello world';"></div>

Related External Links:

Posted in Angular and Tagged with angularjs 

Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts