Answer the question
In order to leave comments, you need to log in
Angularjs how external css and js are connected when using ng-view?
The essence of the question is as follows: there is a main site template, there are several views connected via ng-view. I'm trying to place a jquery gallery on one of them, but it doesn't want to work. sees neither jquery nor gallery styles. When transferring the whole economy to the main page without ng-view - everything works ....... I tried to connect styles and scripts on the view and, accordingly, the main page, combined it in different ways - it doesn't work. Before that, I worked mainly with Django - everything is easier there, of course. If there are connoisseurs, explain the rules for including external css and js in this case.
Answer the question
In order to leave comments, you need to log in
In general, here is an example of connecting a script in a view:
(function() {
var app = angular.module('testApp', [
'ngRoute'
]);
app.config(function($routeProvider) {
$routeProvider.when('/page', {
templateUrl: 'test.tpl.html',
controller: 'TestCtrl'
});
});
app.controller('TestCtrl', function($scope) {
console.log('тут уже можно пользоваться теми скриптами, которые подгрузили во вьюхе');
});
})();
<div class="testView">
<script src="testFunction.js"></script>
</div>
document.addEventListener( "DOMContentLoaded", function () {
alert('Меня подгрузили!!!');
}, false );
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question