我正在使用AngularJS在ASP.NET MVC中创建一个演示项目。我有一个名为'testSomething'的指令,它起初有效。但是在我做了一些更改之后,cshtml页面仍然显示了上一个指令,我的IDE是Visual Studio for Mac。有什么想法吗?
我的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 :(得分: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) {
});