Tagged Questions
0
votes
0answers
19 views
Loading controller on demand using AngularJS
I'm using Angular UI-router and trying to download/load controller when the routing changes. I used resolve and category, the data.data returns the js file content as string. I'm not sure to make the ...
1
vote
1answer
15 views
angular directive not listening to changes in outer scope
I'm currently trying to get my directive to listen to changes happening to a specific variable in the parent scope. For that purpose I came up with the following code which runs fine the first time ...
2
votes
1answer
166 views
Angularjs unit test watch callback not getting called even with scope.$digest
I'm struggling unit testing a controller that watches a couple variables. In my unit tests, I can't get the callback for the $watch function to be called, even when calling scope.$digest(). Seems like ...
-2
votes
2answers
28 views
“Object doesn't support property or method 'push'” [duplicate]
I'm trying to add new value into existing JSON object in AngularJS but I'm getting this error message:
"Object doesn't support property or method 'push'"
Here is my code:
$scope.addStatus = ...
0
votes
0answers
9 views
Angular computed observable on child object
Im trying to make a small test with angular but got some problems I cant get it to work
How do I make an observable in a child object in angular?
The problem with this code is that when I load a saved ...
0
votes
2answers
28 views
AngularJS custom table directive
I have made a table with AngularJS all is working good pagination and sorting but i want to make it as a component so that in other pages it can be used. Right now i have made a factory which calls my ...
0
votes
1answer
22 views
difference between '@' and '=' when testing directives
I'm trying to get my head around testing directives at the moment and have come across some strange behaviour. My code is as follows:
angular.module('tddApp', [])
.directive('oddsButton', function ...
0
votes
3answers
45 views
modify $http code into promise
This is the code I working on.
appControllers.controller('MyaSellerOrderCtrl', ['$scope', '$rootScope', 'Order', '$http',
function($scope, $rootScope, Order, $http) {
...
0
votes
1answer
20 views
AngularJS dynamic Tables and ng-repeat
I am trying to answer my own unanswered question but stuck with some weird results of my code that I can't figure out.
When I generate the whole table by entering common heights and floor numbers and ...
0
votes
1answer
15 views
Defined function not being called
I have a form
<form role="form" name="signup" novalidate>
<div class="form-group" ng-class="{ 'has-error' : signup.firstname.$invalid && ...
0
votes
1answer
21 views
How to check if expression will have a value after evaluating
Let's say I have a following template:
"foo['x'] = '{{ myVar }}';"
Is there an angular way of checking if evaluating this against my current scope will give myVar some value ? I've got an array of ...
0
votes
2answers
33 views
ng-show and $scope.$apply issue
On the HTML I have an overlay div to show a loading progress which uses the directive ng-show="showLoading". On the template ng-click I call the controller searchRequest method. This method updates ...
1
vote
3answers
44 views
AngularJS directives data binding doesn't work
DEMO
Here is a simplified version of the two directives I have, my-input and another-directive:
HTML:
<body ng-controller="AppCtrl">
<another-directive>
<my-input ...
0
votes
1answer
26 views
Socket.io and $scope.$apply()
I'm trying to build a real-time voting app using angular-fullstack. I have everything working except for when I receive a vote, my percentages don't update. I've determined that I need to call ...
0
votes
1answer
17 views
angular directive scope: setting a default value
I'm creating a datepicker directive, part of its markup is:
<select class="form-control" ng-model="day" ng-options="day.nr for day in allDays">
I'm trying to define allDays in the scope ...
0
votes
0answers
26 views
Angular and MEAN.js $scope attributes are undefined
I am currently developing a little app with Angular and MEAN.js.
I would like to plot a D3 chart with some real data coming from the model.
To do so, I would have to read from the $scope.campaign ...
0
votes
1answer
31 views
Load directives based on value
my issue is that I have a directive as follow:
app.directive('bottomNavBar', [function () {
return {
templateUrl: 'views/bottomNavBar.html',
restrict: 'A',
replace: true,
transclude: true
};
...
0
votes
1answer
15 views
AngularJS: How to inherit the scope the directive locates in, and get attributes value same time
Could anybody help with this? Is there a way to access the scope the directive located in (e.g. a controller's scope) while I still can access the attributes' value.
here is my directive code
...
0
votes
2answers
22 views
Angularjs only triggering ng-change on input radio the first time its selected
I have made a simple example using angularjs. This example contains three radio inputs, each of which have to call a function on change (ng-change => console.log). Unfortunately, the function its only ...
0
votes
1answer
24 views
Multiple directives need to share same private scope
I have two directives, one is restricted to the element and the other to an attribute
<bar-foo special></bar-foo>
Now the issue is that the special directive need to define something on ...
3
votes
2answers
35 views
Isolate scope - access scope attributes on element
When creating a directive with isolate scope, I can't access scope properties on the directive element (it's was not the case in angular 1.0.7, but in later versions (e.g. 1.2.17)).
...
1
vote
2answers
33 views
AngularJS dynamic scope variables
I have a scope variable jsonData as below:
$scope.jsonData={id:'1234',abcd:{array:[{a:'data',b:'bdata',c:'cdata'},{a2:'a2data',b2:'b2data',c2:'c2data'}]},efg:{test:'testdata'}}
in my HTML I have a ...
1
vote
1answer
21 views
Using value of complex ng-model in controller from template
I have input box inside a loop in HTML :
<div ng-repeat="line in list.performance_recommendations">
<label>{{line.template.message}}
<input class="k-textbox" ...
2
votes
0answers
34 views
AngularJS: Directive Scope is not getting $destroy called
Been searching for awhile in the archives and on the 'net for an answer, but not really finding one, just bits and pieces. Seems there's a lot of suggested posts, but none of those have the answer.
I ...
2
votes
2answers
2k views
AngularJS: modifying parent scope in ng-include
I found this thread in which the OP's original fiddle where an ng-included scope doesn't modify its parent scope.
One of the replies suggests:
It is ugly and unpredictable, so i recommend you to ...
1
vote
1answer
35 views
How to get field that made form dirty in angular?
Is there any way to know what field made the form dirty in Angular? I have an "auto save" directive that checks if there was any change inside the form, and saves it accordingly (trough server ...
0
votes
0answers
14 views
Nested tree view menu with directives
I have to create a sidebar menu that has two or three levels and that the developer can enable or disable some features, such as icons, labels and animation. I have created four directives, one for ...
0
votes
1answer
7 views
Append directive to body
I have a popup directive, and I would like to compile and append it to body. Is there a simpler way then recompiling and appending directive to body.
link: function (scope, element) {
...
0
votes
2answers
28 views
Inject one service (factory) into another, both of which are async
I should do the following:
query an API for a large dataset of names, probably via a service/factory, using $q (async)
have another service (also async) which should only return elements of the ...
0
votes
1answer
52 views
Angular - Directive attributes vs scope variables
I have some difficulties understanding the directive attributes vs scope variables passed in a directive.
I am working on a directive that dynamically loads the correct template depending on the ...
0
votes
2answers
23 views
What sense does have a new child scope inaccessible from parent controller? (created by ng- directives)
In angular.js Some directives create child scopes. (ng-include, ng-if, etc)
I know there are ways to solve it, for example by declaring the variable in the scope of the controller. Just uncomment ...
0
votes
0answers
32 views
Using scope in Angular directive templates
I have a problem in that I need to toggle some classes based on a value that can only be determined once the template has been compiled.
That's probably not a very helpful description but I'm not ...
0
votes
1answer
36 views
AngularJS - ng-repeat horizontally x number of times, then new line
I am trying to perform a simple ng-repeat on an <li>. In the past, i have created vertical ng-repeat. I am now trying to create a horizontal one, however, one that displays 4 items, then starts ...
0
votes
1answer
11 views
Two way databinding in Angular when using method in template
Is there a way to tell angular that a particular function in $scope is dependant on some other fields in $scope? I would like to hide some functionality in data model, for example:
$scope.user = {
...
0
votes
1answer
25 views
angularjs directive's '$element' is a comment because of ng-if
I'm trying to build a popup (dialog) directive for my angularjs application. (still lots todo...)
However I made a template file which builds the popup element, with insertion of values from the ...
20
votes
7answers
13k views
Angular JS Scaling & Performance
We are pounding our heads against performance issues with an Angular app we are building for a bank.
Unfortunately, it is a breach of contract to show snippets of the code. Regardless, I can describe ...
0
votes
0answers
32 views
AngularJS Directive scope inheritance
I am trying to create a angular tree directive, here is the codes :
//** Tree constructor
var Tree = function() {
return {
restrict: 'EA',
replace: true,
template: "<ul>" +
...
0
votes
1answer
40 views
Why variable in $scope does not update?
Code in plunker.
I have two controllers. In first controller i have handler for button in my view
$scope.click = function () {
$location.url("/some");
console.log("clicked");
}
In handler i ...
5
votes
4answers
11k views
Getting select rows from ng-grid?
How do I create (or access) an array of selected rows in my ng-grid?
Documentation (scroll to "Grid options")
id | default value | definition
...
0
votes
2answers
27 views
$scope array and $scope.$apply in angularjs
I'm learning AngularJs and I'm facing a problem.
I want to show an array of items in a view. First in the controller I define the array using $scope.arrName = [], then I receive data from a third ...
0
votes
1answer
21 views
Call a function on Valid Blur
PLUNKER
How can i trigger function call on blur only if element is valid has no other error?
HtML
<input type="text" id="order" ng-model="order" name="order" class="form-control"
...
0
votes
1answer
11k views
AngularJS: scope of ng-init
What is the scope of ng-init in Angular? Here's a simple example that demonstrates my question:
<div ng-init="model = { year: '2013'}">
<a href="" ng-click="model.year = ...
1
vote
1answer
25 views
Is there a way to pass multiple functions to an AngularJS directive?
I am building a dropdown menu directive which allows you to optionally attach a function to each item in the list. I know how to pass one function per attribute into the directive, but I'm hoping that ...
0
votes
1answer
16 views
Using scope variables with non-form elements
If I have 2 divs (removed ng-click function for simplicity)
<div ng-class="{selected: header.type == 'percent'}" data-type="percent"></div>
<div ng-class="{selected: header.type == ...
0
votes
1answer
37 views
Clean destroy of elements and scopes
The question is how do I clean destroy elements and scopes in AngularJS.
I've got a binary tree structure, which is implemented by recursively using the same directive.
I would like to change the ...
0
votes
0answers
18 views
Get the data on foundation reveal modal
i am trying to search the records with some parameters and get the search result on the reveal modal,i am happily doing with posting the search parameters and getting the data on scope,But not getting ...
0
votes
1answer
39 views
$scope variable has no content
I had controller and function getData as shown. The problem is that the $scope.results outside the for loop has no content. While inside the second http.get request, It has content.
...
1
vote
1answer
34 views
checking function when model changes in other instance of the directive?
In angularjs I have made this simple example with two inputs. I want to change the background color of a input to green if its value its equal to 'green'. This example works, (it changes the ...
1
vote
2answers
35 views
In my service-factory I lookup up a large dataset - I want to persist it and check for its existence to avoid calling it again
My service (factory) makes an API call and assigns response data to a variable:
.factory('MedicationMatchingNamesFactory',
['$http', '$q', 'MedicationDisplayNamesFactory',
...
0
votes
1answer
68 views
How do I $watch the Angular-ui's new ui-select (former ui-select2) search string changes?
I noticed that the Angular-UI have discontinued their UI-Select2 directive in favor of the new UI-Select (with multiple themes - select2, bootstrap, selectize).
It looks like this:
<ui-select ...