2016-03-31 2 views
0

現在、ホームページにページを読み込もうとしていますが、作成できません。私は初めてページを読み込むので、app/index.htmlに連れて来ました。ページをapp/homeにリダイレクトすることは可能ですか?AngularJSメインコントローラ

これは私のapp.jsコードです:

(function() { 

"use strict"; 
//start a new application, a module in Angular 
//Application name 
//dependencies are passed through an array 
angular.module('MovieApp', ['ngRoute']).config(
    [ 
     '$routeProvider', function ($routeProvider) { 
      $routeProvider. 
       when('/home', { 
        templateUrl : 'js/partials/home.html', 
       }). 
       when('/category', { 
        templateUrl : 'js/partials/category-list.html', 
        controller : 'CategoryController' 
       }). 
       when('/category/:categoryid', { 
        templateUrl : 'js/partials/film-list.html', 
        controller : 'MovieController' 
       }). 
       when('/actor/:filmid', { 
        templateUrl : 'js/partials/actor-list.html', 
        controller : 'ActorController' 
       }). 
       when('/movieList', { 
        templateUrl : 'js/partials/allmovie-list.html', 
        controller : 'AllMovieController' 
       }). 
       when('/search', { 
        templateUrl : 'js/partials/search.html', 
        controller : 'SearchController' 
        // controllerAs: 'movies' 
       }). 
       when('/login', { 
        templateUrl : 'js/partials/login.html', 
        controller : 'LoginController' 
        // controllerAs: 'movies' 
       }). 
       when('/logout', { 
        templateUrl : 'js/partials/login.html', 
        controller : 'LogoutController' 
        // controllerAs: 'movies' 
       }). 
       when('/filmDetails/:filmid', { 
        templateUrl : 'js/partials/note.html', 
        controller : 'FilmDetailController' 
       }). 
       otherwise({ 
        redirectTo : '/' 
       }); 
     } 
    ] 
); // end of config method 
}()); // end of IIFE 

これは私のindex.htmlページです:

<header> 
    <div id="header" data-ng-controller="IndexController"> 

    <ul> 
     <li><a href="#/home">Home</a></li> 
     <li><a href="#/movieList">Movie List</a></li> 
     <li><a href="#/category">Category</a></li> 
     <li><a href="#/search">Search</a></li> 
     <li ng-hide="loginEnabled"><a href="#/login" >Login</a></li> 
     <li ng-hide="logoutEnabled"><a href="#/logout">Logout</a></li> 
    </ul> 
      <h2>{{Message}}</h2> 

    </div> 
</header> 

<div id="content"> 
    <!-- <h1>Welcome to FMS Website</h1> --> 
    <article data-ng-controller="CategoryController"></article></br></br> 
    <article data-ng-view></article> 
</div> 

誰かがこの上で私を助けることができます。ありがとうございました。

+0

uは/家にそれ以外の場合は設定しようとしたがありますか? – chancyWu

答えて

0

あなたはこの

when('/', { 
     templateUrl : 'js/partials/home.html', 
}) 

を試してみました。あなたのホームページにそう

+0

ありがとうございました – anonymous5671

+0

あなたの歓迎..... – uzaif

0

変更、

otherwise({ 
      redirectTo : '/home' 
      });