How to use directive that sits in a different module
Asked Answered
P

1

10
angular.module('mod1', [])
  .directive('myDir', ($timeout) => {
    return {
      ///....
    }
  });

angular.module('myApp', ['mod1'])
<html ng-app="myApp">

<body>
  <my-dir valu='blablabla' />
</body>

</html>

So why this wouldn't work? and say Unknown provider: $compileProvider,

but if I move directive into myApp module it works

President answered 18/1, 2013 at 21:17 Comment(4)
Are you trying to use the $compile service somewhere in your directive? If so, you need to inject it (like you do with $timeout).Meaganmeager
but no if I move it into myApp module it worksPresident
Can you post a plunker or fiddle?Gussiegussman
@Agzam, something must be going on somewhere else in your code, because I've created a fiddle just like your code above and it works fine.Benedictus
C
8

I think it should work fine as long as module dependency has been provided correctly !!

Check this out : http://plnkr.co/edit/Wvb7melvMOgXh3FyoVnx?p=preview

Casady answered 27/1, 2013 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.