2017-05-16 28 views
0

我正在用AngularJS在ASP.NET MVC中創建一個演示項目。我有一個叫做'testSomething'的指令,它起初工作。但是,在我做了一些更改後,cshtml頁面仍顯示以前的指令,我的IDE是Visual Studio for Mac。有任何想法嗎?AngularJS代碼不會更新到cshtml?

我AngularJS指令代碼

app.directive('testSomething', function() { 
    var notes = {};  
    notes.restrict = 'E'; 
    notes.template = "@Display()"; //Display() will return a string   
    return notes; 
}); 

我CSHTML頁

<div data-ng-controller="forumCtrl"> 
    <test-something></test-something> 
</div> 
+0

你期待什麼樣的變化? 'cshtml'是一個源文件,你的意思是生成的html? – Icycool

回答

0

將您的指令控制器外,

app.directive('testSomething', function() { 
    var notes = {};  
    notes.restrict = 'E'; 
    notes.template = "@Display()"; //Display() will return a string   
    return notes; 
}); 

app.controller("forumCtrl", function ($scope) { 
}); 
+0

當我複製並粘貼代碼時,這是一個錯誤,該指令位於控制器之外 –