Tagged Questions
The AngularJS controller exposes the data that is to be displayed into the html view. It plays the essential role of the ModelView in the MVVM design pattern. The view is a part of the HTML template.
1
vote
3answers
39 views
Get Current Controller Name in AngularJS
I'm trying to write a directive that will generate a grid. The following code works but I have to specify the controller name 'DemoCtrl'. Is it possible to retrieve the current controller name from ...
1
vote
1answer
25 views
I am getting Error: [ng:areq] Argument 'nameController' is not a function
I am getting following error
Error: [ng:areq] Argument 'nameController' is not a function, got undefined ...
1
vote
1answer
27 views
Binding issue in AngularJS
I am trying to bind from a http get request. The http get is returning true or false. I have tested the get and it is returning properly. When I run the code below, it shows the alert(1111) ...
1
vote
2answers
32 views
Pass model variable from controller to html using AngularJS
I am very new to AngularJs. In my example I am trying to read two initiger value from controller model and multiple that numbers in html page by using AngularJs tag.
controller
(function (angular) {
...
1
vote
1answer
44 views
Pass variable from directive to controller
I have this directive definition and want to pass currentScriptPath to the TestController.
How do I do that?
(function(currentScriptPath){
angular.module('app', [])
.directive('test', ...
0
votes
1answer
16 views
Controller running Parse query before scope variable resolved
I currently have a dashboard that has a variable x that is needed throughout my application. I have a factory in my dashboard.js that listens for x's value to change and updates it if needed. ...
0
votes
3answers
30 views
Add a Controller in angularjs
I am trying to create a controller for a view in angularjs. I just created the file detailCtrl.js in the controller folder with this content
angular.module('frontendApp').controller('detailCtrl', ...
0
votes
1answer
43 views
Angular Structure Incorrect Somewhere
All i am trying to do is call my back-end through an ng-Click and $http.get. I am then trying to set the value of the item i get to show up in my html. Here is my structure. Not really getting any ...
2
votes
4answers
379 views
AngularJS: Cannot interpolate attribute from first directive to a second. (w/ plunker example)
Reference
Reference plunker: http://plnkr.co/edit/otv5mVVQ36iPi3Mp0FYw?p=preview
Explanation of the issue
Suppose that we have two directives, first-directive and second-directive. Now suppose we ...
0
votes
1answer
27 views
Angular JS controller
I am a little confused in the syntax for the controller in angular js:
Both the following controller work when I use {{ and }}.
Could someone tell me what is use of the parameters $scope and $filter ...
2
votes
2answers
35 views
What is the difference between these two angularjs controller definition
I don't understand the difference between these two types of angularjs controller definition,
i have tried following codes and found both working
myApp.controller('GreetingController', ['$scope', ...
0
votes
2answers
38 views
Add new text box on click of a button in angular js
How do I add new text box when submit button is pushed. This is what I have tried and I know there's some thing wrong. I am still new to angular js.
Example:
<!doctype html>
<html ...
1
vote
1answer
43 views
How to keep entered data of page1 after navigating back from page2 in AngularJS
I have three pages with routing. If I entered some input and getting some result on first page, next I navigated to second page and finally I came back from second page to first page. Then I want to ...
-1
votes
1answer
19 views
angular directive call to controller method with parameter
I have a controller with method that gets a parameter,
and I want a directive to call that method and pass the parameter.
how do I add a tag to the controller when a user clicks a tag inside the ...
6
votes
2answers
103 views
+50
Angular ui-router resolve value as string
With ui-router, I add all resolve logic in state function like this;
//my-ctrl.js
var MyCtrl = function($scope, customers) {
$scope.customers = customers;
}
//routing.js
...
0
votes
1answer
43 views
Same “controller as” name in angular js directive breaks function in parent controller
I've a controller with some items for ng-repeat and each item should get a random color so I use ng-style with a function in that controller called randColor(...).
app.controller('TestController', ...
0
votes
3answers
26 views
How can I add a directive from a module to a controller?
I've seen directives created like so:
angular.module('docsSimpleDirective', [])
.controller('Controller', ['$scope', function($scope) {
$scope.customer = {
name: 'Naomi',
address: '1600 ...
0
votes
1answer
26 views
How to use Ionic Popup with scope in Controller As syntax?
I have an Angular controller setup using Controller as syntax and I need to create an Ionic Popup with a bound data field from one the methods. What I can't figure out is how to set the scope of the ...
0
votes
0answers
24 views
angularjs TypeError: Cannot read property of undefined
Hey guys I'm having some issues with the following code as it is producing a TypeError even though I thing I've made sure that all the appropriate directives are accounte for
...
1
vote
1answer
20 views
AngularJs factory function undefined in controller
I used to make it work the exact same way before, and it's driving me crazy. I want to perform a $http GET call into a factory and then get back the result into the controller, to be processed.
The ...
0
votes
0answers
35 views
Angular.js testing controllers: specifying dependencies via $provide vs $controller
While reading articles, guides and SO q&a about testing Angular.js controllers, I've noticed that people in general use two different techniques of providing dependencies to a controller.
...
0
votes
0answers
32 views
Unit testing controller triggering custom directive
Suppose you have an angular+jasmine app and your controller looks something like this:
app.controller('MyController', function($scope) {
$scope.myFunc = function() {
$scope.myArray = [];
...
8
votes
2answers
47 views
List dependencies injected
Is there a way to know what dependencies were injected into my Angular module?
angular.module('myModule', [
'ui.bootstrap'
])
.controller('myController', [function () {
// var dependencies = ...
0
votes
1answer
61 views
Submitting Form in AngularJS and MVC 4
I am new to AngulaJS, and I am trying to do as many examples as I can. I found an example online that works pretty well except for the registration part. I tried to register a user; it did not submit ...
0
votes
2answers
19 views
Unable to boradcast event from parent controller in angularjs
I have a two controller having parent-child relationship:
This is the route for parent controller:
angular.module('app')
.config(function ($stateProvider) {
$stateProvider
...
0
votes
1answer
36 views
AngularJS - Controller not working inside a diretive
Im trying to get some variables or call some methods from a controller of a directive but it is not working.
I have imported all needed files injected everything needed.
If I use the same approach ...
0
votes
1answer
34 views
my Controller is working fine but Directive is not
ok, so this is my AngularJs Controller which have Directive as well.
now when i run application the main page i design for this controller is working but when i tried to re-use it as directive then i ...
0
votes
1answer
27 views
Error: g.setClass is not a function
I am getting this error on my page when I bind a model using the ng-model.
This is how I have written the code -
<section class="row">
<div class="col-xs-6">
<h2>Login ...
0
votes
1answer
33 views
Form validation on multi-step form
I'm trying to add validation to my form but I'm a real newbie when it comes to Angular. The form (that I didn't create) looks like this:
<div>
<div ng-switch="step">
<div ...
1
vote
1answer
34 views
How to call function in controller in angularjs?
If in url parameter id is available then i want to call function.
.controller('repeatCtrl', function($scope,$state,$stateParams) {
if($stateParams.id != ""){
//Here i want ...
1
vote
1answer
29 views
controllerAs with directives and isolated scope
I want to create a ok / cancel button set where the developer can change the label
I have the following directive
angular.module('myApp')
.directive('myButtons',function(){
var ctrl = ...
1
vote
2answers
68 views
Controller being called twice in Ionic (AngularJS)
In my angular project the user accepts a EULA then get automatically redirected to their dashboard, however, on this redirect the DashboardController seems to be being called twice, the ...
0
votes
1answer
32 views
unable to update controller model value from custom directive with controller as syntax
I am facing problem to update my model values from custom directive using controller as syntax. I can clearly see that through console.log that the values are getting changed in the directive however ...
0
votes
1answer
22 views
Testing variable binding using Controller As syntax
I'm trying to test a simple form controller using the controller as syntax. What I want is to be able to pass in different field values to each unit test and see how the controller reacts. The code ...
2
votes
1answer
83 views
Breaking change from between AngularJS 1.2 and 1.4?
The following code works in Angular 1.2 but breaks in 1.4 with error Error: [ng:areq] Argument 'MyController' is not a function, got undefined. The code comes from the book "ng-book", and a live ...
1
vote
1answer
19 views
Assigning controller to a form template with $routeProvider in AngularJS
I'm building my first angular app, starting with a simple login form. I load the form from a partial, however when I try submitting the form, nothing is logged to the console, i.e. I assume my ...
2
votes
1answer
38 views
Can an Angular controller bind to multiple parts of a web page?
Suppose that I've written a web page that requires the user to key in data into forms. Suppose that there are two parts of the page that are completely separate in the DOM, yet are logically related. ...
0
votes
0answers
16 views
$rootScope.$on in controller Angularjs with websocket service
I am using websocket to broadcast data to controller. Full code for the websocket factory is at: angular websocket factory.
In controller I receive data:
$rootScope.$on('broadcast', function () {
...
2
votes
2answers
40 views
Assign multiple controller in $stateProvider.state
Probably this is an easy question for advanced angular users, but I did not find this issue somewhere well explained.
So I was restructuring my code, when I realized, I have two controllers in a ...
2
votes
1answer
31 views
Invoking element directive from controller
I have an element directive that i need to invoke from a controller,rather than writing that in html file.
Element Directive:
angular.module("providerApp")
.directive("openTab", function () ...
0
votes
1answer
41 views
Angular Contoller is not defined
Error: [ng:areq] http://errors.angularjs.org/1.3.15/ng/areq?p0=homeController&p1=not%20aNaNunction%2C%20got%20undefined
I am getting the above error
Controller.js
...
0
votes
1answer
27 views
How to get Angular controller members in non-Angular code?
I'm sticking my toe in the Angular ocean. I have a web application that uses jQuery to allow the user to interact with the application using input forms and buttons. I'm learning Angular and as an ...
0
votes
1answer
30 views
controller undefined error while working with custom directives
I am getting the following error when I am trying to run tabs application and is not working. Please find the plunker. Can any one help me to make it work?
Error: enTabsController is undefined
I ...
0
votes
1answer
20 views
Slim Post method not working with AngularJs Http Request
This is my AngularJS controller :
app.controller('emailConfirmCtrl', function ($scope, $http) {
$scope.check_credentials = function () {
var request = $http({
method: 'POST',
url: ...
0
votes
1answer
16 views
angularjs : I have one form it has many fields some of them carrying array to display dropdown. is it wise that we should provider?
I have one form which has 10 to 12 fields which contains dropdown and multi select drop down. I want before my controller function gets called all the fields should filled up. I tried something like ...
0
votes
0answers
18 views
How can I efficiently use window scroll detection in Angular that can be used by multiple other directives/controllers?
I'm building an animated landing page using AngularJS. I am wondering what is the "best-practices" way of detecting page scroll, in a way that the scrollTop value can be passed off appropriately and ...
0
votes
2answers
65 views
Can I require a controller, in a directive, set with ng-controller?
I have (sort of) the following html:
<div ng-controller="MyController">
<my-sub-directive></my-sub-directive>
</div>
how the controller looks is not ...
3
votes
0answers
133 views
Unable to get AngularJS controller object
In my non-angular code I am getting controller object through following code
var controllerElement = angular.element('[ng-controller="' + controllerName + '"]');
var controller = ...
0
votes
1answer
36 views
Why controller as is undefined?
I've forked some code on Plunker in AngularJS and am trying to rewrite it with John Papa's conventions in mind.
I get an error:
Argument 'testCtrl as ctrl' is not a function, got undefined
Why ...
1
vote
3answers
97 views
Get value from Directive into Controller
So I have this filter directive:
app.directive('filter', function(){
return {
restrict: 'E',
transclude: true,
scope: {
callFunc: '&'
},
template:
' ...