我的模板没有被解析

时间:2012-09-13 03:55:11

标签: javascript angularjs

angular.module('dodgie', []).config(function($routeProvider){
    $routeProvider.when('/home', {template:'/partials/home.html', controller:dodgieCtrl   }).
      otherwise({redirectTo:'/home'});
});

function dodgieCtrl($scope, $location){
    $scope.doSearch = function(){
        if ( !$scope.newTodo.length ) {
          return;
        }
    };
};

内容:

<div id="content" ng-view></div>
而是

 <span class="ng-scope">/partials/home.html</span>

为什么我的部分不被渲染?

2 个答案:

答案 0 :(得分:4)

看起来像拼写错误templateUrl而不是template

angular.module('dodgie', []).config(function($routeProvider){
    $routeProvider.when('/home', {templateUrl:'/partials/home.html', controller:dodgieCtrl   }).
      otherwise({redirectTo:'/home'});
});

取自docs

  • template - {string =} - html模板作为字符串,应由ngView或ngInclude指令使用。此属性优先于templateUrl。
  • templateUrl - {string =} - 应由ngView使用的html模板的路径。

答案 1 :(得分:1)

如果您打算指定网址,请使用'templateUrl'而不是'template'。

相关问题