Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use directive that sits in a different module

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

like image 823
iLemming Avatar asked Jan 18 '13 21:01

iLemming


People also ask

How to use a custom directive in multiple modules and components?

How to use a custom Directive in multiple modules and it’s components? To make a directive available at all places, we need to create its own module to import and export it. Sounds weird? Let’s create a simple directive which will add an asterisk ( *) sign to required fields:

How to make a directive available at all places?

To make a directive available at all places, we need to create its own module to import and export it. Sounds weird? Let’s create a simple directive which will add an asterisk ( *) sign to required fields: In addition to the above code for the directive, we will also add its own module with export and import properties having this directive:

What is a using directive in C++?

The using directive allows you to use types defined in a namespace without specifying the fully qualified namespace of that type. In its basic form, the using directive imports all the types from a single namespace, as shown in the following example: You can apply two modifiers to a using directive:

What is the purpose of the opens directive?

The opens directive can typically be used when you want to allow other modules to use reflection for the types in the specified packages, but not to use them during compile time. Let's make this more clear by means of an example.


1 Answers

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

like image 169
Ashish Avatar answered Oct 01 '22 12:10

Ashish