Can't add any new Angular Module - angularjs

In Jhipster v3.9.1,
i tried add module to my projet, but i can't .
For example, i want to add this module http://hakib.github.io/MassAutocomplete/
so i run bower install angular-mass-autocomplete --save
after i run gulp inject:vendor and gulp inject:dep
So the index.html is refreshed now and the module is there 👍
So when i want to use it, i tried to add the .$inject=[] array , it didn't work, i tried use it next to module, it didn't work too ! .module('moduleName', ['mass-autocomplete'])
It gives me always this error :
angular.js:13920 Error: [$injector:unpr] Unknown provider: mass-autocompleteProvider <- mass-autocomplete <- ControllerName
Can't we use a bower module or NPM module ??
Thank you

The first javascript example on linked page shows the injection
var app = angular.module('app', ['ngSanitize', 'MassAutoComplete']);
when in your question you do it like
.module('moduleName', ['mass-autocomplete'])
change 'mass-autocomplete' to 'MassAutoComplete' and it should work - unless you didn't included the JS library in your output JS

Related

Injecting angularFileUpload not working

this sound like a simple question but i am a newbie with angular, basicly i want to use AngularFileUpload to upload images on my website, so i did this when i initialize my app:
var app = angular.module('myApp',['ui.router'],['angularFileUpload']);
before i installed the angularFileUpload module trough npm, so my module is inside node_modules, but i get an error evertyme i start my app
error:
Failled to instantiate module due to:
'fn' is not a function, got string.
someone know what is happening?
That happens because you are injecting the modules in a wrong way.
You are inserting two arrays:
var app = angular.module('myApp',['ui.router'],['angularFileUpload']);
Instead you should insert just one array with all modules:
var app = angular.module('myApp',['ui.router','angularFileUpload']);
You should use bower instead of npm for loading your client side dependencies in AngularJs. There are following steps required to correctly load your module:
Download using following bower command
bower install angular-file-upload
Then include this library in the script tag, by providing correct location to minified js.
Last inject modules in correct way
var app = angular.module('myApp',['ui.router','angularFileUpload']);
And that's it. Please let me know if it helped you!

In angularJS, having trouble instantiating main module

Every time I try to inject a dependency, I get this error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module marbleApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:
Error: [$injector:nomod] Module 'ngRoute' 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.
I started with this, and my code ran fine:
var app = angular.module("marbleApp", []);
But then when I try to inject a dependency like this, I get the above error...
var app = angular.module("marbleApp", ["ngRoute"]);
Any thoughts on why this could be happening?
remember that you have to check two things when you want to inject some dependencies:
First:
var myModule = angular.module('myModule', [
'myDependency',
'mySecondDependency'
]);
Second:
myModule.config(['myDependency', 'mySecondDependency',
function(myDependency, mySecondDependency) {
//here you can use injected stuff
}
]);
Cheers!
Did you install angular-route, to start with?
$ bower install angular-route
If you want to update your bower.json, too:
$ bower install angular-route --save
More, as the comment from #ddepablo suggests, double check you have it added in your index.html file:
<script src="angular-route.js">
(see https://docs.angularjs.org/api/ngRoute)

angular/browserify: Failed to instantiate module ngResource

I am testing browserify with angular. I have installed ng-resource to my project:
npm install --save ng-resource
I am loading it like this:
require('angular');
require('ng-resource');
require('angular-ui-router');
var app = angular.module('app.module', ['ngResource']
but receive the following error:
Failed to instantiate module app.module due to:
Error: [$injector:modulerr] Failed to instantiate module ngResource due to..
As far as I know I do not have to load ng-resource explicitly when I am using browserify... What am I doing wrong here?
Are you sure you are requiring the correct library? Do you probably mean the official angular-resource?
Please compare https://www.npmjs.com/package/ng-resource and https://www.npmjs.com/package/angular-resource
I think the latter is the one to go with. The ng-resource package somehow seems to be a private port which is no longer maintained...
Try installing the angular-resource module
npm install angular-resource --save
and adapt your code as follows:
require('angular-resource');
angular.module('app.module', ['ngResource']);

AngularJS LocalStorageModule is not available

I'm attempting to get a brand new Ionic project working with angular-local-storage with no luck. I'm somehow referencing angular-local-storage incorrectly, but I don't know how.
https://github.com/grevory/angular-local-storage
ionic start myApp tabs
cd myApp
ionic platform add ios
ionic build ios
bower install angular-local-storage
// app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'LocalStorageModule'])
Then
ionic serve
Error
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module LocalStorageModule due to:
Error: [$injector:nomod] Module 'LocalStorageModule' 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.
What simple thing am I missing?
I'm not familiar with ionic, but it looks to me like you're missing the script.
Are you sure that you have the script included on the page? I'd confirm that bower did indeed install the script where you think it should be and then make sure its actually referenced before this error is thrown.
Guy should need to check that have you added link to it's script
src="https://rawgit.com/grevory/angular-local-storage/master/dist/angular-local-storage.min.js"
using <script></script> tag in your index file. It might be the issue. For the guys who will see this in future.

Bug elixir gulp --production angularjs

I working with Laravel 5 and Angularjs, Laravel 5 uses Gulp for schedule asset's task and all work fine when use gulp's command, but when I use gulp --production's command and gulp minimize the Angularjs library, the console's chrome output:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: e
Below my code:
gulpfile.js
First step, I copy all javascripts from bower folder to assets/js
.copy(
'resources/assets/bower_resources/angular/angular.js',
'resources/assets/js/vendor/angular.js')
.copy(
'resources/assets/bower_resources/angular-bootstrap/ui-bootstrap.js',
'resources/assets/js/vendor/ui-bootstrap.js')
.copy(
'resources/assets/bower_resources/ng-busy/src/angular-busy.js',
'resources/assets/js/vendor/angular-busy.js')
.copy(
'resources/assets/bower_resources/angular-ui-notification/dist/angular-ui-notification.js',
'resources/assets/js/vendor/angular-ui-notification.js')
second step, I put together all libraries copied inside one file "libraries.js"
.scripts(['vendor/angular.js',
'vendor/ui-bootstrap.js',
'vendor/angular-busy.js',
'vendor/angular-ui-notification.js',
'app.js'],'public/scripts/libraries.js')
My app.js
var app = angular.module('app', ['ui.bootstrap','ngBusy','ui-notification']);
app.config(function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
I try different combination, but not working.
Please help!
Have you tried using inline annotation for dependency injection?
Here's a previous question that solves this problem
"Uncaught Error: [$injector:unpr]" with angular after deployment

Resources