2015-06-23 110 views
1

有史以來最沒問題的問題。 這裏是我的代碼: App.coffee:AngularJS路由問題

window.app = angular.module "my_super_app", [ 
    'router' 
    'ng-rails-csrf' 
] 

router.coffee:

angular.module "router", ['ngRoute'] 
    .config ($routeProvider) -> 
    $routeProvider 
     .when '/', { 
     controller: "MainCtrl" 
     } 
    .controller 'MainCtrl',() -> 
    console.log "test" 

Whyyyyyy它不工作?哭泣,把我的頭撞在桌子上... P.S.我故意將控制器添加到路由器中。

回答

1

我明白了。它需要在佈局中使用ng-view,在when部分中需要templatetemplateUrl