$ routeProvider的问题

时间:2015-01-20 14:59:24

标签: javascript angularjs

嘿,我已经开始学习angularJS,而且我很陌生,所以我最好的办法就是问别人。

所以我的$ routeProvider并没有把我发送到任何东西,当我运行它时它不会加载任何部分当我看到控制台得到这个消息错误:[$ injector:modulerr]由于以下原因无法实例化模块collectify:[$ injector:modulerr]无法实例化模块ngRoute。

app.html

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="angular.js"></script>
    <script type="text/javascript" src="angular-route.js"></script>
    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="routing.js"></script>

    <!-- Controllers -->
    <script type="text/javascript" src="src/controllers/categoryController.js"></script>
    <script type="text/javascript" src="src/controllers/itemController.js"></script>

    <!-- Directives -->
    <script type="text/javascript" src="src/directives/itemDecoratorDirective.js"></script>

    <!-- Services -->
    <script type="text/javascript" src="src/services/itemProvider.js"></script>

</head>
<body ng-app="collectify">
    <div ng-view></div>
</body>
</html>

app.js

var app=angular.module('collectify',['ngRoute']);

routing.js

'use strict';
app.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider
      .when('/items/',{
                controller:'itemList',
                templateUrl:'views/item/list.html'
            })
  }]);

itemController.js

'use strict';
app
    .controller('itemIndex',function($scope){

    })
    .controller('itemList', function($scope,itemProvider){
        $scope.items=itemProvider.getItems();
    })
    .controller('itemCreate',function($scope){
        $scope.test="toto";
    })
    .controller('itemRemove',function($scope){

    })
;

我的服务itemProvider.js

'use strict';
var items=[{'libelle':'Transporteur','id_category':1},  {'libelle':'Taken','id_category':1},{'libelle':'Ahmed','id_category':2},    {'libelle':'Muslim','id_category':2} ]

app.service('itemProvider',function(){  this.getItems=function(){       return items;   } })

我的指令itemDecoratorDirective.js

'use strict';
app.directive('decorateItem',function(){
    return{
        template:'Le film "{{item.libelle}}" dont la categorie est {{item.id_category}}'
    }
})

我的观点list.html

<div>
    <div ng-repeat="item in items">
        <p decorate-item></p>
    </div>
 </div> 

0 个答案:

没有答案