I copied the example of ng-include from the tutorial ngInclude but it doesn't seem to work. I tried defining the templates as script partials (as in the jsFiddle of the tutorial), and it works, but when I keep them as separate files in the same folder (template1.html
and template2.html
), it stops working.
Again, my code is EXACTLY as in the tutorial:
index.html
<!doctype html>
<html ng-app>
<head>
<script src="http://code.angularjs.org/1.0.6/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div ng-controller="Ctrl">
<select ng-model="template" ng-options="t.name for t in templates">
<option value="">(blank)</option>
</select>
url of the template: <tt>{{template.url}}</tt>
<hr/>
<div ng-include src="template.url"></div>
</div>
</body>
</html>
template1.html
Content of template1.html
template2.html
Content of template2.html
script.js
function Ctrl($scope) {
$scope.templates =
[ { name: 'template1.html', url: 'template1.html'}
, { name: 'template2.html', url: 'template2.html'} ];
$scope.template = $scope.templates[0];
}
Thanks,
Frank
UPDATE:
Resolved. The problem apparently was caused by trying this on Chrome.