'use strict';
angular.module('myApp', ['myApp.controllers', 'ngRoute']);
angular.module('myApp').config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/view1', {
controller: 'Controller1',
templateUrl: 'partials/view1.html'
})
.when('/view2', {
controller: 'Controller2',
templateUrl: 'partials/view2.html'
});
$locationProvider.html5Mode(true); //activate HTML5 Mode
});
Controller is:
'use strict';
angular.module('myApp.controllers', [])
.controller('Controller1', function ($scope) {
$scope.message = "Hello, world";
})
.controller('Controller2', function ($scope) {
$scope.now = new Date();
});
Html Page is:
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>AngularJS Routing</title>
<link rel="stylesheet" href="app.css"/>
<base href="/">
</head>
<body>
<ul class="menu">
<li><a href="/view1">view1</a></li>
<li><a href="/view2">view2</a></li>
</ul>
<ng-view></ng-view>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.js"></script>
<script src="app.js"></script>
<script src="controllers.js"></script>
</body>
</html>
Can anyone help me to solve the problem
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/kKJnWINld1s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});