2015-05-22 32 views
0

這是我的索引頁templateUrl與自己的工作中AngularJs指令

<link href="~/Content/bootstrap.min.css" rel="stylesheet" /> 
<script src="~/Scripts/angular.min.js"></script> 
<script src="~/Content/efDirective.js"></script> 
<script src="~/Content/EmployeeForms.js"></script> 

<html ng-app="AngularModule"> 
<body> 
    <div employee-form></div> 
</body> 
</html> 

這是DirectiveJs

var app = angular.module("AngularModule", []); 
    app.directive("employeeForm", function() { 
     debugger; 
     return { 
      restrict: 'EA', 
      //template: 'helloworld', 
      templateUrl: 'Content/efTemplate.html' 
     } 
    }); 

含量efTemplate.html沒有顯示index.cshtml頁面上。

回答

0

檢查瀏覽器控制檯中的消息,可能會有一些錯誤消息。也許URL模板沒有正確解析? 您是否指定了角度的基礎網址?

另一種選擇是直接在html索引文件中預渲染模板。這有利於保存額外的http請求。 像這樣:

<script type="text/ng-template" id="templateUrl"> 
    <h1>your template </h1> 
</script> 

例這裏https://docs.angularjs.org/api/ng/directive/script