Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module('ngView', [], function($routeProvider, $locationProvider) {
- $routeProvider.when('/angular/:bookId', {
- templateUrl: 'tpl/detal.tpl',
- controller: BookCntl,
- });
- $routeProvider.when('/angular/:name/:chapterId', {
- templateUrl: 'tpl/detal.tpl',
- controller: ChapterCntl
- });
- $routeProvider.otherwise({redirectTo: '/angular'});
- $locationProvider.html5Mode(true).hashPrefix('!');
- });
- function MainCntl($scope, $route, $routeParams, $location) {
- $scope.$route = $route;
- $scope.$location = $location;
- $scope.$routeParams = $routeParams;
- }
- function BookCntl($scope, $routeParams, $http) {
- $http.get('angular/' + $routeParams.bookId).success(function(data) {
- $scope.book = data;
- });
- $scope.name = "BookCntl";
- $scope.params = $routeParams;
- }
- function ChapterCntl($scope, $routeParams, $http) {
- $http.get('angular/' + $routeParams.name + '/' + $routeParams.chapterId).success(function(data) {
- $scope.book = data;
- });
- $scope.name = "ChapterCntl";
- $scope.params = $routeParams;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement