Created
March 7, 2015 20:18
-
-
Save kpko/bd0231ccefbaf8c415c7 to your computer and use it in GitHub Desktop.
ngRoute example with two views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular-route.js"></script> | |
</head> | |
<body ng-app="myApp"> | |
<a href="#/pms">PMs</a> | <a href="#/pms/5">PM Box</a> | |
<div ng-view></div> | |
<script> | |
var app = angular.module('myApp', ['controllers', 'ngRoute']); | |
app.config(['$routeProvider', function ($routeProvider) { | |
$routeProvider.when('/pms/:box', { | |
controller: 'pmBox', | |
templateUrl: 'pmBox.html' | |
}).when('/pms', { | |
controller: 'pmList', | |
templateUrl: 'pmList.html' | |
}).otherwise({ | |
redirectTo: '/pms' | |
}); | |
}]) | |
var controllers = angular.module('controllers', []); | |
controllers.controller('pmList', function ($scope, $routeParams) { | |
console.log($routeParams); | |
}); | |
controllers.controller('pmBox', function ($scope, $routeParams) { | |
console.log($routeParams); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment