I've cloned this repo: https://github.com/Hyra/Frickle
Its quite awesome! But I'm trying to add more angular modules and I'm not succeeding.
In the main directory I run npm install angular-animate. This adds the angular-animate folder files to the node_modules folder within the project right alongside the other angular modules and the angular library itself.
In the package.json file, I've added to the dependencies angular-animate by adding the following
"dependencies": {
"angular": "~1.3.0",
"angular-ui-router": "~0.2.11",
"angular-animate": "~1.3.5",
...
In main.js
'use strict';
require('angular');
var uiRoute = require('angular-ui-router');
var ngAnimate = require('angular-animate');
var app = angular.module('MyApp', [uiRoute, ngAnimate]);
Angular-ui-router works fine in the original setup. The stack uses gulp and browserify to concatenate and minify the javascript files but as I'm kind of new to angular, I'm not sure why I'm having issues adding a simple dependency to this stack. Hopefully this is simple and someone can tell me what I am doing wrong.
The error I get in the console is as follows:
Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to:
Error: [$injector:modulerr] Failed to instantiate module {} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object
This looks really strange: var app = angular.module('MyApp', [uiRoute, ngAnimate]);
According to: https://code.angularjs.org/1.3.10/docs/api/ng/function/angular.module
The requires array is supposed to be an array of strings. So it should really be:
var app = angular.module('MyApp', [uiRoute.name, ngAnimate.name]);
Related
I am working with Angularjs 1.6 and ui-grid 4.4.2 and I hit a snag. I need my grid column widths to expand to the widest content in the column. I found an NPM Package that does this but I am unable to install it.
When I include the package in my angular module I get the following error:
Unhandled exception at line 5014, column 9 in http://localhost:29236/Scripts/angular.js
0x800a139e - JavaScript runtime error: [$injector:modulerr] Failed to instantiate module CRNApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.grid.autoFitColumns due to:
Error: [$injector:nomod] Module 'ui.grid.autoFitColumns' 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.
Part of my Angular definition:
(function () {
'use strict';
angular.module('CRNApp', ['ui.bootstrap', 'ui.grid', 'ui.grid.autoFitColumns', 'ui.grid.autoResize', 'ui.grid.emptyBaseLayer', 'ui.grid.selection', 'toaster','ngAnimate']);
MainController.$inject = ['$scope', '$http', '$uibModal', '$log', 'uiGridConstants', '$rootScope','toaster'];
angular.module('CRNApp')
.controller('MainController', MainController);
The installation instructions are at https://github.com/Den-dp/ui-grid-auto-fit-columns
The install command is: npm install ui-grid-auto-fit-columns -S
After I typed int he NPM install command I saw a new set of folders appear:
I am inexperienced with Angularjs and NPM so I am not sure what I am doing wrong. Any ideas?
I forgot to import the .js file in my bundleconfig.cs file.
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
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)
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.
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