我的模板未被解析

my template is not being parsed

本文关键字:我的      更新时间:2023-09-26
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>

为什么我的部分没有被渲染?

看起来像一个错字尝试templateUrl而不是template

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

摘自文档:

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

如果要指定 url,请使用"templateUrl"而不是"template"。