简体   繁体   中英

Meteor AngularJS application not loading directive

I have a simple directive, <my-directive></my-directive>

client/scripts/directives/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:

<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.module('myApp', ['angular-meteor'])

Also, my templateUrl differs from yours. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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