All Questions
Tagged with angularjs-controller dependency-injection
21
questions
18
votes
4answers
29k views
AngularJS: Inject controller inside another controller from the same module
Is possible to inject a controller into another controller that is part of the same module?
example:
var app = angular.module('myAppModule', [])
.controller('controllerOne', ['$scope', function(...
5
votes
5answers
2k views
Why wouldn't you use explicit annotations when defining controllers in AngularJS?
I am new to AngularJS and learning about the two styles of writing controller functions. It seems as though the only reason someone would not use explicit annotations is to save time, which doesn't ...
3
votes
1answer
2k views
AngularJS constants undefined is not an object
new to Angular and I'm trying to inject constants from a separate file. It seems to work with the DI, but when I try to use it, I get an error: Error: undefined is not an object (evaluating '...
3
votes
1answer
3k views
TypeError: Cannot read property 'get' of undefined Angularjs
Im try to use Oboe.Js and Angular.Js together
Here is my sample code which is working correctly..
angular.module('myApp', ['ng-oboe'])
.config(function (oboeProvider) {
/* If we were ...
2
votes
1answer
122 views
Angular: Not able to access variables in controller using service
I am trying to share a variable between a controller and a function. But i get an error from the controller, saying this:
TypeError: Cannot read property 'getSet' of undefined
I have gone through ...
2
votes
2answers
2k views
TypeError: api.getAll is not a function, service method is not recognized
I have a very simple service and a controller attempting to get some information from it, but I keep getting .methodName is not a function.
Here is the service, apiService.js :
(function (module) {...
2
votes
2answers
71 views
How do I know what dependencies I can inject into a controller?
I am trying to use $routeProvider dependency inside my controller:
.controller('mainController', function($scope, $state, $routeProvider) {
But I am getting the error:
Error: [$injector:unpr] ...
1
vote
4answers
46 views
angularjs app not working after code concatination
I have and angularjs app.I want to concatenate all the JS files to a single file.I'm currently trying to use Grunt.js to setup an automatic build process for concatenating JavaScript files.
However ...
1
vote
1answer
7k views
AngularJS : Using factory inside a controller
This is my first attempt to use the Angularjs and I'm trying to create a service and use it inside a controller:
var appTest = angular.module("appTest", ["ngRoute"]);
var appTestControllers = angular....
1
vote
2answers
259 views
AngularJS issues with injecting a new service into my controller
I have a new userContext.js file which attempts to create a new service entitle "userService". This service in turn will communicate with the server and return some environmental settings, as well as ...
1
vote
2answers
306 views
Service undefined when injected into controller
I have a controller that I have injected a factory into but it comes back as undefined when I call a method on that factory. Not sure what I am doing wrong here. Any help would be appreciated.
...
1
vote
1answer
678 views
Inject percentage filter in controller
When invoking ng-strict-di on my ng-app I receive an error "Error: [$injector:strictdi] percentageFilter is not using explicit annotation and cannot be invoked in strict mode" on line
<span ng-...
1
vote
1answer
181 views
Angular: Dependency Injection with prototypal inheritance
According to Todd Motto's styleguide, Controllers chapter:
Inheritance: Use prototypal inheritance when extending controller classes
I try to implement it in my controllers:
function ...
1
vote
1answer
515 views
Cannot call another function from within scope onSubmit function
I have a very simple form template and controller. But i'm unable to call a function from within the onSubmit scope function. Controller is:
angular
.module('myApp')
.controller('...
1
vote
2answers
1k views
AngularJS - Is there a way to inject data into a controller without using routes?
I have a controller in my angular application that requires some server-side initialization. I would like to do it synchronously, meaning that the data should be fetched before the controller is ...
0
votes
2answers
3k views
Angular Typescript: Unable to inject $filter in controller
I am using a controller inside my directive. I have declared a function (change(searchAttribute: string)) in controller constructor which will internally use the filter but i am getting runtime ...
0
votes
3answers
885 views
TypeError: $controller is not a function + Controller inside controller
I am new to Angular JS and trying to call a controller inside another controller but getting below error.
ionic.bundle.js:21157 TypeError: $controller is not a function
at new <anonymous> (...
0
votes
3answers
619 views
cannot access angular service from external js file
this is my html:
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&...
0
votes
1answer
116 views
Angular module injection error
I am trying to create a sample Angular app with .Net, just to get the idea how to connect two of them but I can not get rid of this injector::modulerr error. Tried variety of things, changing ...
0
votes
0answers
20 views
How should a controller be specified in a directive?
Assume we have these 2 snippets, what's the difference between controller: function (...) { } and controller: 'myController'
app.directive('testDirective', function () {
return {
restrict: '...
0
votes
3answers
2k views
Unknown provider error when trying to dependency inject a service to a controller in AngularJs
I'm new at Angular and trying to do a basic dependency injection to get the hang of it. In this example I'm trying to dependency inject a service to a controller, and I'm getting the following error.
...