The angularjs controler 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.
0
votes
0answers
29 views
Using two Controllers in single script file
Here I'm using single script file to declare two controllers.
My index.html
<html ng-app="myApp">
<head>
<title>Lesson 4 - Tuts + </title>
<script ...
0
votes
1answer
8 views
Binding global scope variable to directive local variable
I'm having trouble understanding scope linking between controllers and directives.
What I'm trying to do (which should help me learn a lot) is bind $scope.systems in my controller to data in my ...
0
votes
0answers
17 views
AngularJS - Strange behavior with broadcast events
I have app-controller.js which send events across different states using UI Router which are nested in a view:
app-controller.js
// Online
document.addEventListener("online", function(){
...
-2
votes
1answer
38 views
AngularJS injecting data from factory to controller
I trying to get some data and then pass it to the controller for further processing. I have setup a factory to get the data but having issues passing it to the controller and getting it working. Below ...
0
votes
2answers
27 views
Angularjs Cannot get the correct data from a service in a controller
I try to build a mobile app with Ionic/Angular/Cordova, and I have some problems with a service :) My code looks like this :
SERVICE:
'use strict';
...
0
votes
1answer
22 views
initializing ng-app with name disables varibles initialization
With following:
<div ng-app="" ng-init="show_login=false;count=0">
<button> ng-click="show_login=!show_login;count=count+1">INSPIRE</button>
<form ng-show= "show_login">
...
0
votes
2answers
31 views
$http.get is undefined when $http is used outside angular code
I am running jasmine unit test against a method which is outside angular controller.
Running the jasmine throws the following error,
TypeError: Cannot read property 'get' of undefined at ...
1
vote
2answers
32 views
AngularJS - Error: [ng:areq] Argument 'CustomersController' is not a function, got undefined
Here is my view index.html:
<!DOCTYPE html>
<html ng-app>
<head>
<title>Iterating Over Data</title>
<link href="styles.css" rel="stylesheet" type="text/css" ...
0
votes
1answer
15 views
Running AngularJS test for controller after changing $scope to this
I am following the angularjs tutorial here : https://docs.angularjs.org/tutorial/step_02
My original controller:
var phonecatApp = angular.module('phonecatApp', []);
...
0
votes
2answers
19 views
chaining ngResource $promise success and errors
I'd like to know if it's possible to handle the $promise returned by ngResource on multiple levels so that the code is DRY
here is a simple example
aService = function(aResource) {
var error, ...
0
votes
1answer
22 views
Angular watching Service properties
Take the following plunk as an example:
http://plnkr.co/edit/vKFevXhhSprzFvesc6bG?p=preview
var app = angular.module('plunker', []);
app.service('SomeService', ['$rootScope', function ($rootScope) ...
0
votes
0answers
25 views
$watch on directive link function does not read updated value
So i've been going around this one the whole morning. And after going through the docs and a lot of stack overflow questions I decided to throw the towel.
Scenario is, I have a directive where on the ...
0
votes
2answers
35 views
Angular.js: Data binding not working with directives controller option
Why is angular's data binding not working when I specify a controller in the directives controller option? $scope.emailInvalid.text normally should get mapped to type.text but in my case, nothing ...
1
vote
1answer
20 views
Function in AngularJS controller not being called
I am trying to call a function from my AngularJS controller with the following code:
Controller Code
(function () {
var hello = angular.module("helloApp", []);
...
1
vote
4answers
47 views
AngularJS $http use response in multiple controllers
I have an app where I am loading a bunch of albums in one partial and then when a user clicks on each individual album, they get details for the album like songs, etc. Right now I am pulling the data ...
1
vote
2answers
54 views
How to initialize form as scope variable in controller
I have a simple angular form
<form name="myForm" ng-controller="myFormController"></form>
and need to call $setPristine() to myForm in myFormController. What is the best way to ...
0
votes
0answers
22 views
Creating a directive that will generate menu items using ng-repeat inside a defined template
I have a template as below:
<li ng-click="action()">{{name}}<i class="icon-li{{icon}}"></i></li>
The action() is something that will change as per the JSON object and ...
0
votes
1answer
29 views
Need to stop ongoing operation when controller becomes background (or invalid)
I'm writing my first AngularJS application. The landing page has two links #/view1 and #/view2. Every link will call individual controller to render <div ng-view></div> individually.
The ...
1
vote
0answers
46 views
Angularjs, need best solution to move dynamic template formation and compilation code of multiple directives from controller to custom directive
I need to display multiple angularjs directives in a single page on tab click. It could be a combination c3 chart directives and ng grid directives. I am preparing the model with all these relevant ...
0
votes
0answers
24 views
How to watch the active tab in angularjs to be able to call $interval.cancel function for running scripts in different tab?
I'm using angular and my app consists of different content. Tab 1 contains widgets, while the rest is plain text.
This is one of the controllers that will get the data of widget from server. I have ...
0
votes
1answer
49 views
AngularJS Controller instance method
I have an angular js controller that I am writing in a way so other controllers can inherit from it. Instead of defining the function as a single one in the angular's controller function I am writing ...
1
vote
2answers
30 views
View does not reflect the data from $http.get(inside an angularjs controller)
Im using AngularJS and I'm creating a controller which is connected to the view. This controller gets data from the server every 10secs and the idea is to display/show the data to the client. My ...
2
votes
2answers
42 views
Can we access user input value in customfilter.Trying to access user input number from controller or directly in customfilter
I am new to angular js .Here I am trying to filter data based on the temperature by subtracting the user input(x) from the currentTemp variable.But not sure if i could access the user input value in ...
0
votes
0answers
24 views
How to dynamically include controller from string for directives?
I need to dynamically choose the controller at ngRepeat based on component name as a string. Plunker: http://plnkr.co/edit/osLLf0c4eNCpNokyyXCI?p=preview
As you can see I found a solution, but I ...
0
votes
2answers
58 views
How to access asynchronous angularjs service data out of the call back function
I have a form submission where I need to validate my email id separately. Based on email Id validation (Using validationService) I will be submitting the form and will call formSubmissionService from ...
0
votes
2answers
30 views
Services are not resolved in my controller
Angularjs controller unable to resolve the service data.
var kattaApp = angular.module('kattaApp', []).controller('kattaController', function($scope, dataFactory) {
var promise = ...
0
votes
1answer
55 views
Angularjs: Using ng-class to add a class to completed progress step
I am trying to add a class to a completed step indicator on the progress bar but cannot figure out how to do it. A step is completed when a button is clicked on the page and takes the user to the next ...
0
votes
1answer
81 views
Dynamic update of ng-include through controller and directive Angualar-js
Left side of the page sometimes have just info, sometimes it has side menu. When there is side menu, the content of main section depends on the option clicked.
Since the same kind of layout is used ...
0
votes
1answer
29 views
Trigger $modal.open from app.js
My app.js looks something like this. I need to handle the AJAX errors globally.
This code works fine if I were to use only console.log. However, I need to trigger a modal dialog by using $modal, but ...
0
votes
0answers
42 views
Generate Templates in Angular JS dynamically based on server side configuration file
Folks, I am willing to create a user interface that will work with any storage server that exposes them over REST api. Here is more detail and challenge faced :
A configuration file resides ...
3
votes
1answer
43 views
set/get data in service from controllers
Just trying to figure out how some of this works so I want to input a number in a view then have the controller set that data in the service and switch views. Then the controller for the next view ...
0
votes
2answers
75 views
I am trying to understand AngularJS's controllerAs syntax
However after writing up a few examples to play around with the controllers would not load. I was getting an error:
firstController is not a function
After some googling I found that Angular 1.3.x ...
6
votes
1answer
79 views
how to refresh AngularJS object without data loss?
I have used two different controllers (assume: myCtrl1 and myCtrl2) and I set a button on myCtrl1. When we hit this button the action goes to myCtrl2 via ajax call. Now I'm append some data on ...
0
votes
2answers
33 views
Angular Js : Button click to get data from two controllers and showing it in third
I am new to AngularJS. i am having a following functionality where i am having a FirstName field and LastName Field(in two Different Controllers) and then on the click of a button i want to show ...
1
vote
2answers
29 views
AngularJS: Sharing Data between 3 Controllers
I am using factory method in AngularJS to show the combination of First Name and Last Name (first two controllers) as Full Name(in third Controller), but i am not getting the desired output. here is ...
0
votes
1answer
31 views
Setting up watches in Angular controller vs. more complex template
I'm looking for the proper place to put some presentation-related logic in Angular. I'm new to Angular, so I'd like some general guidance as to the proper Angular way to approach a problem like this.
...
2
votes
1answer
66 views
Inheritance w/ Angular's 'Controller As' vs. $scope
tl:dr;
I want to consider the 'controller as' approach to simplify my inheritance process however I see some pitfalls around dependency injection and use in directives.
preface
I've been working ...
0
votes
2answers
39 views
Communicating between controllers in AngularJs
I have a simple question: what's the best ('cleanest', 'scaleable') path one should go when it comes to interact between (let's say) two controllers. Would that be to define a service and watch that ...
1
vote
1answer
66 views
Using controllerAs syntax in Angular, how can I watch a variable?
With standard controller syntax in AngularJS, you can watch a variable like:
$scope.$watch(somethingToWatch, function() { alert('It changed!'); });
Using the controllerAs syntax, I want to react to ...
0
votes
1answer
62 views
Controller function being called but not executing AngularJS [closed]
I am trying to call a controller from the view. I used Chrome dev tool and I know that the controller is being called, but not execute.
My goal is to call the server to get more information about a ...
2
votes
1answer
26 views
angularjs scoped function fires more often than invoked
I have a scoped function that fires more times than is invoked and can't figure out why. I've created a small example in plunker and snippets appear below. when the page is loaded you would think that ...
0
votes
2answers
42 views
How can we broadcast angularjs promise to different controllers?
How can we broadcast updated data from factory.
Am having two factories and two controllers.
Service1: updates the data into db
app.factory('uac',function($http,$q, $cookies)
{
formData.uClient = ...
0
votes
2answers
66 views
AngularJS - passing variable to scope (from directive to use it in controller) not working
I would ask for some help and explanation on the given issue. It seems like I can not pass variable to scope from directive to use it in controller, variable is called caret_position. Please see below ...
1
vote
1answer
80 views
Update Angular ion-view in another controller
Im new here on stackoverflow and new to AngularJS.
Im trying to build a Ionic app, and here is my problem.
I would like to change the date in one template(date.html), using Controller: DateCtrl, and ...
0
votes
2answers
30 views
Communicate to another, specific controller
I'm a bit lost... I'm quite new to Angular and writing a small app for practicing.
I've two views with a table and each view has it's own controller. The tables use some equal functions, like edit, ...
0
votes
2answers
82 views
angularjs multiple nested parent children directives communication
I have a directive which contains a child directive which also contains a child directive, and I am trying to use the top most parents controller to access the grandchild's controller and call a ...
1
vote
1answer
95 views
angularjs service - controller - view data binding
I am trying to bind data between a service, controller and a view. Below, I have provided plunker link for the app.
Basically 'dataService' has a function to find geolocation. The function sets the ...
1
vote
2answers
54 views
How to set ng-show on a specific element through different views/controllers?
Plunker: http://plnkr.co/edit/0efF1Av4lhZFGamxKzaO?p=preview
Below is my header, there is an ng-show="cornerLogo" which I only want to be set true on the about, login and register views, but false ...
0
votes
1answer
30 views
Why can't I create this controller in my test?
I have a controller that seems to work very well. I need to write test cases so I added the following in a beforeEach(). The $controller is being injected into the beforeEach, as is the $rootScope ...
2
votes
1answer
146 views
AngularJS 1.3.8 Using multiple controllers, second controller is not working
How do you use multiple controllers for AngularJS 1.3.8?
I've tried the following below but only the first controller outputs correctly and the second controller outputs with {{ name }} and {{ age ...