angularjs-injector

Creating a generic angularjs listController

馋奶兔 提交于 2019-12-01 19:43:09
Angular ui-router allows me to resolve different injections that I can use in my controllers. I created a simple generic ListController, and in the ui-router I am injecting an object that contains the CRUD functions specific for that particular view, along with the template. So, for example, let's say I have 2 services with the same "crud" syntax: addPerson(person, callback){} deletePerson(person, callback){} editPerson(person, callback){} .... addCar(car, callback){} deleteCar(car, callback){} editCar(car, callback){} .... I created a mapping object to map these services' CRUD functions into

Module is not available, misspelled or forgot to load (but I didn't)

允我心安 提交于 2019-11-30 11:20:12
问题 I am fairly new to angular and using it with JSON api files. TO test, I am trying to use the free github api (my names for functions are for a different json api that i will be working with later). I just wanted to see if my functions were working with console.log() , but i receive this error in the console. Uncaught Error: [$injector:modulerr] Failed to instantiate module MesaViewer due to: Error: [$injector:nomod] Module 'MesaViewer' is not available! You either misspelled the module name

Are ES6 arrow functions incompatible with Angular?

半城伤御伤魂 提交于 2019-11-29 05:58:10
Here's a normal ES5 function in my Angular code which works: app.run(function($templateCache){ $templateCache.put('/some','thing') }); I wanted to convert it to ES6 arrow function app.run($templateCache => $templateCache.put('/some','thing')); but it gives the error Uncaught Error: [$injector:unpr] Unknown provider: '/some'Provider <- '/some' http://errors.angularjs.org/1.4.6/$injector/unpr?p0='%2Fsome'Provider%20%3C-%20'%2Fsome' REGEX_STRING_REGEXP @ angular.js:68 (anonymous function) @ angular.js:4287 getService @ angular.js:4435 (anonymous function) @ angular.js:4292 getService @ angular.js

$provide outside config blocks

删除回忆录丶 提交于 2019-11-26 23:17:53
I'm certainly missing some fundamental point about the injector, but I fail to understand why exactly this angular.module('app').config(function ($provide) { ... }); and this angular.module('app').config(function ($injector) { $injector.invoke(function ($provide) { ... }); }); work as intended, while this app.run(function($provide) { ... }); will throw Error: [$injector:unpr] Unknown provider: $provideProvider <- $provide As follows from the above, config has some special relationship with providers, while run deals with instances, yet I'm unsure about the thing that makes config blocks so