I'm using SPA with Angular and trying to use some jquery in my page after rendering the a particular page. But the problem is that the jquery code doesn't work and no errors on the console either.
Hope you can help me out, here is my code:
app.js:
var app = angular.module('app', ['ngRoute', 'angularCSS']);
app.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'pages/main.html',
controller: 'mainController',
css: 'styles/main.css'
})
.when('/second', {
templateUrl: 'pages/second.html',
controller: 'secondController',
css: ['styles/second.css', 'styles/second_2.css']
});
});
app.controller('mainController', ['$scope', function($scope){
}]);
app.controller('secondController', ['$scope', function($scope){
}]);
the main page, index.html:
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>Untitled Document</title>
<meta charset="UTF-8">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="styles/viewbox.css">
<script src="https://code.angularjs.org/1.3.0-rc.1/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.0-rc.1/angular-route.min.js"></script>
<script src="angular-css.js"></script>
<script src="app.js"></script>
</head>
<body>
<div>
<h3><a href="#/">Main</a></h3>
<h3><a href="#/second">Second</a></h3>
</div>
<ng-view></ng-view>
</body>
</html>
and here is the template, second.html:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/jquery.viewbox.js"></script>
<script>
$(function(){
$('img').click(function(){
alert("my img");
});
})
</script>
<h1>Hello, this is Second Page</h1>
<img src="pic1.jpg" alt="" width="250" height="250">