Sunday, February 8

Angular Js - ng-include accepts an expression

Angular js provides a very good functionality or to be more precise a directive to include external files, just like in php (include(“filename.php”);). This directive is ng-include.

To use it you must pass the path of the file as an expression/string to the src attribute where you will be using the ng-include. See below

<div ng-include src=”'templates/header.tpl.html'”><div>

P.S :
1) Don't forgot the include ng-app directive in your HTML file.
2) Include your ng-app directive to the HTML tag. Including it to the doctype does not work. For example the below code will not instantiate ng-app
<!DOCTYPE HTML ng-app=”myApp”>

Instead, you could include your ng-app directive to the HTML tag
<html ng-app=”myApp”>

Reference :

Be the first one to Comment!!!

Post a Comment