Tagged Questions
0
votes
2answers
23 views
AnuglarJS - Parsing multiple .then in controller from factory data
I have a controller calling to any set of specified methods in a factory to retrieve information on a given date. Some of the methods iterate through a JSON file to return promise. See factory below ...
0
votes
0answers
16 views
detect which directive calling a method in the controller
is there any way to detect which directive calling a function in the controller without passing any arguments from the directive itself.
simple example to demonstrate what i need:
controller:
...
0
votes
1answer
19 views
Angularjs app logic structure help required
I've recently started with Angular and would really appreciate some help on how to properly structure my code the angular way. This is more of a meta question rather then technical question.
I have ...
0
votes
1answer
20 views
AngularJS - mechanics of $scope.$watch - is it just an observer pattern?
I have some factory:
.factory("someFactory", function() {
var someFactory = {};
someFactory.objects = [
{ name: "obj1" },
{ name: "obj2" }
];
return someFactory;
}
And some ...
0
votes
1answer
17 views
Is $routeChangeSuccess guarantied to be fired inside a newly instantiated controller?
Suppose we have an /example route and the ExampleCtrl associated:
.when('/example', {
templateUrl : 'example.html',
controller: 'ExampleCtrl'
})
&
ExampleCtrl = function(){
...
1
vote
1answer
36 views
Service vs Inheritance for Access Parameters Outside `ng-view`
Is it more effective to use a Service or rely on Scope Inheritance when updating parameters outside an AngularJS ng-view?
I have an AngularJS page with an ng-view and a common header. When moving ...
0
votes
1answer
54 views
AngularJS remove $rootScope from a service
I have a service wrapped around WebSocket, I wanted to do it with promises and coupling requests with responses, here is what I came up with:
(function () {
var app = angular.module('mainModule');
...
0
votes
2answers
106 views
AngularJS: open a new browser window, yet still retain scope and controller, and services
I'm writing an angularJS app. In this particular controller, I open a new browser window through the $window.open service. But in the new window, all the $scope variables are lost.
I tried to use ...
0
votes
2answers
89 views
From an AngularJS controller, how do I resolve another controller function defined in the module?
Self explanatory fiddle: http://jsfiddle.net/5FG2n/6/
I need to dynamically choose the controller to use at runtime based on its name as a string. The string will be read from a config object.
In ...
0
votes
1answer
64 views
How do I properly set a service property from model data in a controller in angularjs?
I've set up a service to share some data/state between multiple controllers. In one controller, I update some of the service properties with scope data through a save function. That data is then used ...
3
votes
1answer
65 views
How do I resolve and assign an inner controller from the outer's scope?
Self explanatory fiddle: http://jsfiddle.net/5FG2n/1/
Say I have a view with two controllers, one containing the other. The outer controller is static, but I need to set the inner controller based ...
0
votes
2answers
38 views
AngularJS Services - using in Controller
I'm building a pretty simple app where I have a GlobalController (on body element), and will have another sub-controller below. This is a templated site with multiple, physical pages such that the ...
2
votes
2answers
83 views
Did I share state correctly outside angular directive? (parent scope / $rootScope issue)
I have two elements on my page which are not nested in some way. With attributes on the first one, I would like to set the content of the second one, like so:
<body>
<input info="This is ...
0
votes
2answers
166 views
How to access the value of one controller from another controller in angularjs
I have two controller in an angularApp with following codes
Controller:Devicectr
function Devicectr($scope, $http) {
$scope.Devices = [{ Id: 1, Devicename: "MasterDeviceA" },
{ Id: 1, ...
0
votes
1answer
43 views
Directive Inside another directive. Controller can't watch
I have 2 simple directives...
the parent directive:
.directive('modal', [function () {
return {
replace: true,
scope: {
/* attributes */
},
templateUrl: 'modal.tpl.html',
transclude: ...
0
votes
1answer
220 views
Share data between two controllers in angularjs using restangular
I am fairly new to angularjs, so please bear with me.
I have two controllers, one of which has a Restangular call to load a certain json object. How do I access this same json object in another ...
0
votes
1answer
42 views
Why isolate scope “@” and $apply don't work as expected
I've been studying AngularJS and in particular saw the video:
http://www.thinkster.io/pick/IgQdYAAt9V/angularjs-directives-talking-to-controllers
This video presents an example of a directive ...
1
vote
1answer
31 views
Angular not scoped method
I am wondering, does all the methods declared in an angular controller have to be added to the scope?
is it possible to call a controller method from ng-click="myMethod()", with my method not delared ...
0
votes
0answers
630 views
Setting Model in AngularJS Control Not Updating View (something…)
I am experiencing issues with updating values in my AngularJS controller and having them properly reflecting in my model.
I have the following form in my view:
<form name="formSignIn" ...
2
votes
0answers
316 views
Nested directives - cannot pass args to controller method from child directive in Angularjs
I'm having some trouble with nested directives in angularjs. I want to call a controller method from a directive within another directive and am trying to pass arguments to it, however they are ...
1
vote
2answers
117 views
Evaluating expression in ng-controller
My Javascript
var app = angular.module('Demo', []);
app.controller('DemoCtrl', function ($scope) {
$scope.expr = "Test"
});
app.controller('Test', function ($scope) {
$scope.HELLO = "HEllo ...
0
votes
1answer
23 views
How to bind a transcluded template to a different controller?
I'm trying to pass a template through a directive to a dynamic controller (known at runtime from the directive perspective).
Something like this:
<my-dir ctrl="PersonCtrl">
...
0
votes
2answers
46 views
$watch's object not triggered when attributes are changed
I have one object:
$scope.obj = {bar: 'bar value', foo: 'foo value'};
and I want to to know if bar, foo or both change.
I'm doing this:
$scope.$watch('obj', function() { console.log("watching ...
0
votes
0answers
251 views
ng-repeat load new updated array model but do not clear the previous value of array in template
I have a list of articles, every article has a list of comments with user.name and user._id of that comment. Click to each user, it shows a chat box to send message to that user. Everything is ok with ...
0
votes
2answers
89 views
AngularJS controllers communication
I'm not sure I'm doing what I need in the right way... I have 2 controllers:
SiteMenuCntl and DashboardCntl
SiteMenuCntl is bound to a UL tag, and it's the menu of the site. By default it's hidden, ...
0
votes
1answer
461 views
Trigger the $scope.submit() event of blueimp in angular programmatically
When I use the submit() event of blueimp file uploader within the DOM, everything seems to work fine. i.e.:
<span class="btn" ng-click="submit()">Go</span>
However, calling ...
5
votes
3answers
10k views
How do I use $rootScope in Angular to store variables?
How do I use $rootScope to store variables in a controller I want to later access in another controller? For example:
angular.module('myApp').controller('myCtrl', function($scope) {
var a = ...
0
votes
1answer
291 views
Re-binding a tree (Wijmo tree) with AngularJS
I am fairly new to AngularJS, and really struggling to re-bind a Wijmo tree (or even a tree implemented using UL and LI elements wth ng-repeat) with new data on changing of value of a Wijmo combobox ...
0
votes
1answer
178 views
Angular access controller scope from nested directive
this fiddle represents what i am trying to do:
http://jsfiddle.net/d1001001/dwqw6/.
The grid directive needs to grab some data from controller, but since it's nested in the modal directive, which has ...
1
vote
2answers
2k views
AngularJS - refresh view after http request, $rootScope.apply returns $digest already in progress
Hey guys so I am simply trying to load data when my app starts. However, the view loads faster than the http request(of course). I want to refresh my view once my data has been properly loaded because ...
0
votes
1answer
199 views
binding a ng-repeat child object to another child object (zipcode +city!)
Mainly psuedo code so please dont mind if there's typos. I'm trying to figure out how to access the value of address.City.ZipCode for my controller method; since this is just a child in the address ...
0
votes
0answers
120 views
How to create nested views and controllers in AngularJS without using ng-controller in the attribute
I have an application wide router, where the routes specify the template and controller to instantiate while navigating:
$routeProvider
.when('/', {
templateUrl: 'views/login.html',
controller: ...
0
votes
2answers
103 views
AngularJS - stops working when using controllers
So I'm just now starting to get into angularJS and things were fine with tests until I got into using controllers with ng-repeat. It seems that when I use it it just doesn't connect to the controller. ...
0
votes
1answer
658 views
Reinitialize an Angular.js controller
if you have a controller to manipulate $scope variables in Angular.js, is there an idiomatic way to:
reset the controller's $scope, and
restart controller initialization?
For complex controllers ...
1
vote
2answers
905 views
ng-repeat not updating using $scope.$watch
I need some help in displaying the results of an update in my ng-repeat directive from $watch
ProductsCtrl is watching for a change of product type and when it detects one it searches for Products ...
0
votes
2answers
364 views
Broadcasting across AngularJS controllers?
How do I broadcast a message between controllers?
Here is what I have tried:
function Ctrl1($scope) {
$scope.$broadcast('Update');
}
Ctrl1.$inject = ['$scope'];
function Ctrl2($scope) {
...
0
votes
4answers
162 views
Unable to share data between AngularJS controllers?
I had seen the egghead.io video on sharing data between controllers, but couldn't get it to work:
var myApp = angular.module('myApp', []);
myApp.factory('QData', function () {
return 'hello'
});
...
0
votes
1answer
47 views
Angularjs two separate ui elements communicating
I have a use case to toggle the view of a form using a button. The button is not nested in the same structure of the form, and is out side the scope of the forms controller.
What is the best way to ...
2
votes
1answer
1k views
How to access the $ngModelController from inside the Controller without a Form and without a Directive
Maybe it's a rookie mistake, but I can't seem to access the $scope.model's $ngModelController so I can grab the $viewValue from it.
I have an input without a form (im using ui-mask directive):
...
0
votes
0answers
92 views
Share data between controllers using permalinks?
I would like to share data between controllers using permalinks, rather than signals or factories.
Given a single page application, with three controllers (Ctrl1, Ctrl2, Ctrl3), and a predefined ...
0
votes
3answers
2k views
$watch not working on variable from other controller?
I have one controller which displays a checklist, and stores the selection in an array.
My other controller runs an $http.get on the array from the first controller.
How do I set a $watch so that ...
6
votes
1answer
3k views
Sharing data between AngularJS controllers? [duplicate]
How do I store the items I've selected in a checkbox with other controllers?
My attempt (see the plnkr for views):
script.js (controllers)
var myApp = angular.module('myApp', []);
...
0
votes
1answer
1k views
Angular: call service once multiple controllers
This should be a fairly straight forward question, but I'm stumped.
I have a service that makes an http call and then does extensive post-processing of the results. I would like the processed ...
2
votes
1answer
2k views
AngularJS The scope for dynamic content through $compile isn't attached to the controller scope
When I generate a new element through a string that has a directive (that's why I need to compile) and that directive generates an association with a variable in the controller scope through "=", the ...