I am currently in the process of learning Angular and have come across some challenges with module resolution. In js/directives/directives.js
, I have a directive scoped within a directives
module:
angular.module("directives").directive("selectList", function() {
return {
restrict: 'E',
link: function() {
// do stuff
}
}
});
When I try to use it on my webpage:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<script>
angular.module("editUserApp", ["directives"])
.controller("editUserController", ['$http', '$scope', function($http, $scope) {
// do stuff here
}]
);
</script>
The error message I'm encountering states:
Error: [$injector:modulerr] Failed to instantiate module editUserApp due to:
[$injector:modulerr] Failed to instantiate module directives due to:
[$injector:nomod] Module 'directives' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
It seems clear that editUserApp
is unaware of the location of directives
. So, how can I instruct it to fetch the directives.js file? Do I need to include it in a script tag (which may not be ideal for scalability)?
I am looking for a way to import directives into my Angular application. Can someone provide guidance on how to accomplish this?