I have index.html which i am able to load but angular-ui-router is not routing it to proper templateURl (app.html is in same deirectoy as of index.html).I have added all the required script but it is not working
<!DOCTYPE html>
<html ng-app ="mustReadAlgo">
<head>
<title>AngularJS Basic Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="lib/css/bootstrap.min.css" />
<link rel="stylesheet" href="lib/css/animate.min.css" />
<script type='text/javascript' src="public/lib/moment.min.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../public/lib/lodash.min.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../public/lib/angular/angular.min.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../public/lib/angular-sanitize/angular-sanitize.min.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../public/lib/angular-ui-router/release/angular-ui-router.min.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../app.js" charset="UTF-8"></script>
<script type='text/javascript' src="../../app/controllers/app.controller.js" charset="UTF-8"></script>
</head>
<body>
<div class="container" ui-view="" ></div>
</body>
</html>
And my app.js is
'use-strict';
angular.module('mustReadAlgo',['ui.router']).config($stateProvider,$urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider.state('home',{
url :'/',
templateUrl : 'app.html',(is in same directory as of index.html)
controller :'mustReadAlgoCntrller'
});
}).run(function(){
});
And controller code is in app.controller.js
angular.module('mustReadAlgo').controller('mustReadAlgoCntrller',function($scope)
{
$scope.message='Hello World';
console.log('inside controller');
});
Content of app.html
<div class="row">
<div class="col-xs-2">
<button class="form-control btn btn-default"><span class="glyphicon glyphicon-thumbs-up"></span>Hello World</button>
</div>
<p>Hello</p>
</div>
But ui routing is not working properly to load the templateUrl? Can anyone please help me out i am new to angular js .
If you are passing straight HTML to use as the template you need to use template:
, not templateUrl:
. Here are the docs on templates.