Tagged Questions
0
votes
1answer
36 views
AngularJS controller scope won't sync with promise
I've picked up a project and I'm trying to return some data from a service to my controller. I've been at this for about 12 hours, and have tried different methods. They all usually result in this ...
0
votes
0answers
21 views
Function decomposition of ngTables?
Attempt:
$scope.ran_before = false;
function table(provider, columns, params, data, parse_data) {
params = new ngTableParams
(
{
page: 1, // show first page
...
0
votes
3answers
21 views
How to escape an angular scope variable in a kiwi template
I have a scope variable (myVar) which is defined in MyController:
angular.module('myApp.controllers').controller('MyController', ['$scope', function($scope) {
$scope.myVar = 'whatsoever';
}]);
...
0
votes
2answers
54 views
Directive talks to controller but cannot call functions residing in controller
I have a directive which needs to call functions from the Main controller but everytime i try to reference a function inside the directive nothing happens because it's undefined. When I access a value ...
1
vote
3answers
64 views
Best practice for defining scope variables
I have this form. This form contains many many inputs like first name, last name, job title, notes, state, department, documents, supervisor...and so on
Originally I had a controller like so
...
1
vote
2answers
35 views
In an AngularJs directive, how do I call its controller's function contained within an directive element's attribute?
I am trying to call a function in a controller, which is part of a custom angular directive, following is the code,
Method 1: (Doesn't work: Controller's function doesn't write to the console)
HTML:
...
1
vote
0answers
65 views
Angular directive in ng-repeat doesn't call link
I'm fairly new to Angular and am having some trouble getting a directive to render within an ng-repeat. This is probably a lack of experience on my part so any help is greatly appreciated.
Here are ...
0
votes
2answers
69 views
AngularJs ngShow triggers double in controller
I have a problem with the controller triggering the method defined on the $scope twice when the page first loads and when the form submits.
Here's the fiddle : http://jsfiddle.net/scabro/pQb6q/5/
...
2
votes
3answers
110 views
How do I access the $scope variable of one controller from another in Angular.js?
I have this:
app.controller('foo1', function ($scope) {
$scope.bar = 'foo';
});
app.controller('foo2', function ($scope) {
// want to access the $scope of foo1 here, to access bar
});
How would ...
1
vote
1answer
135 views
AngularJS sharing data between factory & controller across modules
I have an angularjs app that has several modules. The main modules looks something like:
var app = angular.module('mainMod', ['apiService']);
app.controller('MainCtrl', function (Socket) {
...
0
votes
3answers
63 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
30 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
32 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
129 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 ...
1
vote
1answer
65 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
64 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
93 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');
...
1
vote
2answers
1k 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
281 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
77 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
79 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
48 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
110 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
301 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
48 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
275 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
49 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
705 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" ...
3
votes
1answer
413 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
208 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
24 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
48 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
253 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
103 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
608 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 ...
15
votes
3answers
18k 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
355 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
190 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
3k 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
208 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
132 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
134 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
1k 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
1k 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
536 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
176 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
50 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
101 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 ...