Tagged Questions
0
votes
2answers
27 views
How can I call a function from controller1 in controller2? AngularJS
I have a function defined in controller1 and would like to use it in controller2. When I do $scope.functionName() or even $rootScope.functionName() I get this error
TypeError: $scope.functionName()...
0
votes
1answer
28 views
Scope in custom Directive in AngularJS for checking if a value already exists in DB
I have a problem of scope in my custom directive created for checking if an email already exists in the DB. Indeed the results retrieved by the AJAX query are not returned in the scope (and in my ...
0
votes
0answers
43 views
How to use scope variable in template script after the controller is loaded?
I'm trying to access a variable in scope to use it later (this is an example)
if I insert a setTimeout function it works well, but if I try in this way it prints "undefined" to console. How can I wait ...
0
votes
2answers
22 views
Angularjs calling a service function from the controller
I've been searching the web but I can't find why I get this error
"checkDishService.checkDish is not a function"
in the console when calling a service function from my controller.
Please, help!
...
1
vote
3answers
50 views
List of items not getting added dynamically
I have written this code in AngularJS where I want to add item name, price and quantity. This item is represented in lower table and saved as an array. Later, I am finding the total bill.
<!...
0
votes
1answer
226 views
Upon a input change event, scope variable in controller and Interpolated value of same variable on template are different
I have an app with two routes/templates login and main. The login template's user input values are bound to two scope variables username and isAdmin. The scope variables are initialized with 'abc' and ...
0
votes
0answers
54 views
child of angularjs component
How can a child DOM of an angularjs component access the component's variable values?
To illustrate, I am using angular official website first component example. I added a div inside the component.
...
0
votes
2answers
844 views
accessing angularjs textbox value in a controller
I am trying to learn AngularJS and require help in passing user entered text box text value after button click to append to a string url value while calling the http service.
I'm trying to add in ...
0
votes
1answer
167 views
cannot access directive's scope object in directive's controller
MaterialIn.directive.js
angular.module('mdt')
.directive('mdtMaterialins', materialInsDirective);
function materialInsDirective() {
return {
restrict: 'E',
scope: {
...
0
votes
2answers
61 views
Access to controller scope from $scope.$on in AngularJS
I'm beginner at Angular and I have this simple problem in Angular 1.5. I use rootScope for emit some events and $scope.$on as the event listener in component controller (which provide data for child ...
2
votes
2answers
61 views
Newbie AngularJS Controller $scope cannot read property of undef
I'm trying to solve a problem obviously some of the newbies with Angular experience sometimes. Even there are several posts I did not find the problem with my small example. Scenario:
webpage that ...
0
votes
0answers
30 views
Weird behavior with this and $scope in controller method
Well, I am new to angular and my prior searches showed me that using 'this' is different from '$scope', inside a controller. Bearing that in mind, I decided to only use scope in my application, which ...
0
votes
2answers
62 views
AngularJS: How do I get a variable from a $http. to another controller?
I have been working on an angularjs webapp using WS of moodle to get information, I have a little problem with variables, I would like to get a variable from a $http. and I saw that you can use ...
1
vote
2answers
110 views
how to get access to controller scope when testing directive with isolate scope
I have directive with isolate scope and controller, Is it right to write unit tests for directive and test some functional in controller scope?
And if it right, how i can get access to controller ...
1
vote
2answers
152 views
AngularJS : pass data from controller to controller without factory, service or broadcast?
I don't want to use a service or a factory and would like to pass for example an array of data. I would like to access data in my parent controller from my child component.
Factory and service are ...
0
votes
2answers
117 views
How to call function in controller from another controller?
I have 3 html page. index.html, search-movie.html and result-movie html. I am
redirecting pages with ui-router.
search-movie.html code is as the following :
I have text and button in the html page....
0
votes
1answer
339 views
Call controller function from directive
I'm new to AngularJS.
I want to build an app which could display book information and user could click an icon to remove the book information. I use a customer directive which display each book ...
0
votes
2answers
68 views
ng-class not working with $scope variavles defined in the controller
I can't make my ng-class work using $scope varibales defined in the controller
I tried this:
HTML
<nav id="main-navbar" class="navbar navbar-default navbar-fixed-top"
ng-class="{'on'...
0
votes
2answers
19 views
Different Controllers in Angular based on authentication
I have an app with a JWT authentication. I'm using $stateProvider to navigate into the app. From the server came, with the token, a boolean params (all came via json): isAdmin. Is there a possibility, ...
0
votes
3answers
41 views
AngularJS controller is called twice (with no ui.router)
I have a problem with a controller in AngularJS, it's called twice and it reset my array messages... I want create a simple chat box where a user srite a message, click send and in a div I show all ...
1
vote
1answer
329 views
Listen to mouse events in a custom directive in Angular
I have a custom directive called side-menu, which I can use at my index.html as follows.
<side-menu></side-menu>
Inside the directive, there is a controller. This controller is in a ...
0
votes
2answers
237 views
AngularJS ─ can't get scope by link from the directive controller
I have an example app with very simple structure (you may see it here: http://plnkr.co/edit/5VAqUQsqKFGoteahacR2?p=preview):
The file index.html includes template (app/templates/home.html), which, in ...
1
vote
2answers
52 views
Angular documentation about controller this
I recently read in angular documentation (https://code.angularjs.org/1.4.9/docs/guide/providers) this:
myApp.controller('DemoController', ['clientId', function DemoController(clientId) {
this....
1
vote
1answer
835 views
Accessing child scope from parent
I'm having difficulties figuring how to access child scope data.
I'm using routes and ui-views to create a flow in creating a project, I have the "Wizard" which is the parent, and few more children ...
1
vote
0answers
87 views
image cropper in ng dialog scope value is not updating in controller (Angular.JS)
I am facing a issue, can any one help me out?
angular image cropper in ng dialog, scope value is not updating in controller.
Please help me out.
Thanks in advance.
2
votes
1answer
585 views
Show/Hide an element on base of ng-view content
I have a simple div (class = blue) which I want to show only if I am locating to 'two.html' but not one 'one.html' or 'three.html' in ngRoute - Routing in angular. Can someone have a solution for it?
...
1
vote
1answer
788 views
Pass variable to UI-bootstrap modal without using $scope
Since I am a beginner using AngularJS the $scope approach to pass data between different controllers and (in my case) a modal drives me crazy. Due to that reason, I googled around the web and found an ...
1
vote
5answers
779 views
Angular JS: Using $scope.variable Across Controllers
So, I've got a counter ($scope.counter) that I increment on ng-click. The problem I'm having is that I want to increment it from two different controllers, keeping the counter value in sync.
...
0
votes
1answer
104 views
Running a controller with ng-click
.controller('randomImageController', function($scope, $http, Image) {
$scope.loading = true;
Image.random()
.success(function(data) {
$scope.image = data[0];
$scope.loading ...
0
votes
1answer
378 views
How Angular Controller flow works?
I have the following module:
(function(){
var app = angular.module('ModBrowser',['ModUserCredentials','ModContentGroup']);
app.directive('browser', function(){
return {
restrict: "E",
...
-1
votes
2answers
249 views
AngularJS call a function from another controller
I want to call a function or change the value of variable/s which is there inside another controller. I looked online for the solution and understood that I have to create a service and use it inside ...
2
votes
2answers
509 views
Update $scope variable that is used in ng-repeat, from other controller
I have a controller HomeworkPageController where I get all the topics from MongoDB using method getAllMainTopics from TopicService. $scope.topics is then used to show all topics. I have a button that ...
1
vote
1answer
38 views
Targeting $index from ng-repeat
How would I go about targeting this model in the controller?
formData[$index].ID
This is not working -
$scope.getJob = function() {
Employee.get({id: "" + $scope.formData[$index].ID}, ...
0
votes
2answers
127 views
Using $emit and $on to work with two Controllers in AngularJS
I want to define a communication between CtrlOne (Parent) and CtrlTwo (Child). In this topic was the solution to define scope: $scope but I can't do this because I'm using a service for my modal ...
1
vote
0answers
96 views
How to migrate to a controller-less AngularJS design pattern?
It seems that there is a trend in eschewing designs which lend themselves to massive and unruly controllers for a more directive-based, granular design pattern--Angular 2 seems to be promoting this ...
0
votes
1answer
123 views
how can i use display and use $scope in another controller in angular js
I have a $scope.selected ( a modal that return a value selected ) to be created in ModalInstanceCtrl controller and used in displayValue controller,How Can I spent the first controller value at the ...
-2
votes
1answer
129 views
within AngularJs how can we use registered controller $scope object in other directive module conroller
app.controller('myController',['$scope',function($scope){
$scope.temp = '007'; // my controller variable
}]);
app.directive('mydir', function() {
return {
restrict: 'A',
transclude: true,
...
50
votes
6answers
128k views
How to call a function from another controller in angularjs? [duplicate]
I need to call function in another controller in angular js.How it is possible way please help me thanks in advance
Code :
app.controller('One', ['$scope',
function($scope) {
$scope....
1
vote
1answer
648 views
Scope not being removed
Using angular 1.2.9
Explanation of what is working:
I have a list on the left of the webpage where a user can press + button to append a view to the .viewSpace.
When the user presses +
...
1
vote
2answers
8k views
How do you set $rootScope within Angular Service function?
I'm having trouble setting $rootScope for Angularjs.
Below is my function
App.controller('Controller',
function (UtilityService, $rootScope) {
var setSession = function () {
$rootScope.test = "...
0
votes
0answers
179 views
Sharing data between controllers in AngularJS (PubSub/Event bus example)
I have a page with a list of product. I have a li with my directive that it does is that when I click on a link it is inside of the li and compiled a template inside of the li and show my template.
...
2
votes
1answer
101 views
Angular Scope in a controller
"Angular version": "1.3.8",
I have the following code
The controller is being delivered to the page like so
'use strict';
/**
* @ngdoc overview
* @name testApp
* @description
* # testApp
*
* ...
2
votes
3answers
1k views
AngularJS - Scope not applied in view within controller's function
I'm trying to modify a variable inside $scope within a controller's function and the affectation works, but didn't apply in the view.
app.controller('LoginCtrl', ['$scope', '$http', function ($scope, ...
0
votes
1answer
3k views
how can I access a variable defined in one controller from the scope of another controller?
I have the following controllers:
HeaderCtrl, NewsFeedCtrl, MainCtrl
MainCtrl contains both the other two controllers, which are in the same level.
I'm defining an object in authenticationService ...
0
votes
1answer
111 views
angular edit each post in array
I have an array of posts:
.factory('posts', [function(){
var o = {
posts: [
{title: 'post 1', upvotes: 5},
{title: 'post 2', upvotes: 2},
{title: 'post 3', upvotes: 15}
...
-1
votes
2answers
36 views
AngularsJS list and edit with 2 controllers
I try to do my first angularjs application, but i have a problem. I have 2 controllers (and i would like to keep 2): the first to list items, the second to edit or create an item.
When I save an item,...
0
votes
2answers
89 views
angular how to use scope from a different controller
I have a user.list.ctrl and a user.detail.cntr. All the controllers are build as a module and are injected in a "user-module" which I inject in the app.js. (see the complete code in the plunker ...
0
votes
1answer
73 views
Accessing “inside” $scope without $rootScope
I have this controller, with $scope.go that I trigger with a simple ng-click and a string representing the name of my .json file. I then go to another view and use that .json file :
HTML
<tr ...
0
votes
3answers
3k views
Replace $scope with “'controller' as” syntax
I'm following this AngularJS+ASP.NET tutorial(http://www.asp.net/web-api/tutorials/hands-on-labs/build-a-single-page-application-(spa)-with-aspnet-web-api-and-angularjs) and they make use of the $...
7
votes
3answers
12k views
How to apply a function to an angularjs expression inside a controller?
simple question, I would like to apply a function inside my controller scope to an expression.
This is my HTML inside my controller
<p><span ng-if="paginaDetail.pubdate !== '' ">Vanaf {{...