简体   繁体   English

Meteor AngularJS应用程序未加载指令

[英]Meteor AngularJS application not loading directive

I have a simple directive, <my-directive></my-directive> 我有一个简单的指令, <my-directive></my-directive>

client/scripts/directives/myDirective.directive.js: 客户端/脚本/指令/myDirective.directive.js:

angular
  .module('myApp')
  .directive('myDirective', myDirective);

function myDirective() {
  return {
    restrict: 'AE',
    scope: {
      data: '='
    },
    templateUrl: "'/client/templates/partials/liftOwnerConfirmedRiders.html'",
  };
}

client/templates/partials/myDirective.html: client / templates / partials / myDirective.html:

<p>Hi. How are you?</p>

Why will the text not show when I use the directive in another page? 当我在另一页中使用指令时,为什么文本不会显示?

I had troubles with displaying meteor-angular directives, but they were gone when I've added ['angular-meteor'] to my module definition: 我在显示流星角指令时遇到了麻烦,但是当我在模块定义中添加['angular-meteor']时,它们就消失了:

angular.module('myApp', ['angular-meteor'])

Also, my templateUrl differs from yours. 另外,我的templateUrl与您的不同。 It starts without slash : 它开始时没有斜线:

templateUrl: 'client/templates/tabset.html'

This most commonly happens to me when I fail to reference the directive JS (and any dependencies) in the page. 当我无法在页面中引用指令JS(以及所有依赖项)时,这是最常见的情况。 If you don't load the directive in the page where it's used then it will just be ignored by the browser and won't even throw an error in the console (unless it's missing a dependency too). 如果您不在使用该指令的页面中加载该指令,则该指令将被浏览器忽略,甚至不会在控制台中引发错误(除非它也缺少依赖项)。

As Claies writes, we need more context if you want more than generic responses like this. 正如Claies所写,如果您想要的不仅仅是这样的通用响应,我们需要更多的上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM