angular路由

来源:互联网 发布:如何应对网络谣言 编辑:程序博客网 时间:2024/05/01 15:42

1.app.js

"use strict";(function (angular) {var app = angular.module('moviedog',['ngRoute','moviedog.in_theaters','moviedog.coming_soon','moviedog.top250']);app.config(['$routeProvider',function ($routeProvider) {$routeProvider.otherwise({redirectTo:'/in_theaters'});}]);app.controller('appViewController',['$scope',function ($scope) {$scope.name = '北京电影频道';}]);})(angular);
2.in_theaters
'use strict';(function (angular) {var  module = angular.module('moviedog.in_theaters',['ngRoute']);module.config(['$routeProvider',function ($routeProvider) {$routeProvider.when('/in_theaters',{templateUrl:'in_theaters/view.html',controller:'In_theatersController'});}]);module.controller('In_theatersController',['$scope',function ($scope) {}]);})(angular)

3.index

        <ul class="nav nav-sidebar">          <li auto-focus><a href="#/in_theaters/1">正在热映</a></li>          <li auto-focus><a href="#/coming_soon/1">即将上映</a></li>          <li auto-focus><a href="#/top250/1">TOP</a></li>        </ul>