html - AngularJS: How to load javascript files into the partials using ng-include -
my main javascript files (they in index.html) don't want work in partials (page1.html, etc.).for example jquery, hightlight syntax. problem loading them during click on menu.
html code:
<div data-ng-controller="testctrl"> <ul> <li data-ng-repeat="page in pages"><a href="" data-ng-click="loadpage(page)">{{page.title}}</a></li> </ul> <article data-ng-include="view"></article>
js code
app.controller('testctrl', ['$scope', function($scope){ $scope.pages = [ { title: 'test', url: 'page1.html' }, { title: 'test2', url: 'page2.html' }, { title: 'test3', url: 'page3.html' } ]; $scope.view = $scope.pages[0].url; $scope.loadpage = function($page){ $page.url ? $scope.view = $page.url : ''; };
the content loaded when click in link (page1.html, page2.html, page3.html). script dont want work. problem here?
you mean script in index.html not works in loaded partials?
so think it's related scripts. should initialize scripts again after loading template file.
most of jquery plugins have plugin initializer function, run again. e.g $('.codeblock').highliter();
Comments
Post a Comment