Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 一个简单的角度指令不起作用_Javascript_Angularjs - Fatal编程技术网

Javascript 一个简单的角度指令不起作用

Javascript 一个简单的角度指令不起作用,javascript,angularjs,Javascript,Angularjs,我是初学者。这些是从示例中复制的。他们现在不可能在工作 <html ng-app> <head> <script src="angular.min.js"></script> <script > var app = angular.module("App", []); app.directive("antest", function(){ debugger; return { restrict

我是初学者。这些是从示例中复制的。他们现在不可能在工作

 <html ng-app>
 <head>
 <script src="angular.min.js"></script>
 <script >
 var app = angular.module("App", []);
 app.directive("antest", function(){
    debugger;
    return {
        restrict: "AE",
        templateUrl: "b.html",
        replace: true
        };
 });
 </script>
 </head>
 <body>
    <antest></antest>
 </body>
 </html>

var-app=angular.module(“app”,[]);
应用指令(“antest”,函数(){
调试器;
返回{
限制:“AE”,
templateUrl:“b.html”,
替换:正确
};
});

您已将模块命名为“应用程序”。所以你需要ng app=“app”才能让它工作。

它在做什么,而不是做什么?您的问题是什么?
b.html
包含hanks不会有什么坏处,调试器正在工作,但是b.html内容仍然没有打印出来。b.html看起来像什么?b.html:
  • Windows
  • Linux
  • Unix
XMLHttpRequest无法加载file:///C:/Users/StAR/Desktop/Learning/ng-test/b.html。跨源请求仅支持协议方案:http、数据、chrome扩展、https、chrome扩展资源。@Tan您需要一个正确的http服务器来正确运行/测试您的应用程序。