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
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:
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:
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:
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With