Tagged Questions
AngularJS directives are a way to teach HTML new tricks by extending the HTML vocabulary. Directives allow you to manage DOM elements in a declarative pattern, freeing you from low level DOM manipulation tasks.
2
votes
1answer
1k views
AngularJS - pass parameter from ng-repeat to controller from custom directive
I have a custom AngularJS directive, which is rendering a ng-repeat. In this ng-repeat I want to pass one element to a function. The function is called, but item is undefined.
Important: I get my ...
2
votes
1answer
135 views
Why I can't pass angularJS parameter on onClick html event?
I'm trying to concat a string with a AngularJS expression in html. See the example above:
angular.module("app", []);
function MyCtrl($scope){
$scope.item = "Hello";
$scope.say = ...
2
votes
2answers
3k views
Get attribute as a object properties into directive AngularJs
I my writing universal slider directive for my app, and i need to specify that for example a control buttons in HTML code like this:
<div class="slide-wrapper" data-sample-values="{prevbtn: '....
-2
votes
0answers
20 views
I want to know that maximum numbers of column can be shown in ng-gird?
I have more than 30 colums in ng-grid and but few of the columns are missing and though they are visible on choose column option.
http://embed.plnkr.co/FADs8F/
When defining a rather large number ...
0
votes
0answers
13 views
Angular 1.5 component templateUrl not working
I have just started using Angular 1.5 components and have the following snippet of code
angular.module('vizzle').component('teacher', {
bindings: {},
/* @ngInject */
templateUrl: '/app/...
1
vote
1answer
32 views
How to add item cost in Angularjs?
I want to add work item cost but its show original value.
Example:
item[1].cost =2 ,item[2].cost = 2 ..
When I add 3rd item[3].cost = 8 it's Total = 228. I want add SUM, how to do this? I want ...
1
vote
3answers
32 views
Angular, directive isolate scope
Still trying to learn Angular
I have a plunker here https://plnkr.co/edit/3FLmBtHP5TuOwWZHBMLK?p=preview
I'm just trying to create an example of a directive with isolate scope.
I'm using $http and ...
0
votes
1answer
20 views
ng-enter not working when I use controller as syntax
I am trying to use ngEnter directive in my angular app
app.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
...
2
votes
1answer
528 views
angular custom directive two way binding not working inside uib modal
I'm having difficulties with a custom directive two way binding inside uib-modal.
The directive gets the model variable from the uib-modal scope, but on change, the model in the uib-modal isn't ...
-1
votes
4answers
34 views
AngularJS - TypeError: Cannot read property 'push' of undefined when ng-repeat a div
I am creating an ionic mobile Apps project. I want to display a particular div multiple times in a html page. After that, I would like to display images etc. for each of the div.
Here are my codes ...
0
votes
0answers
20 views
High chart with angular directive in dynamic ionic slide box
I want to create dynamic slide box with high chart with directive . I created directive to show high chart and it is working fine .
codepen.io/anujsphinx/pen/JbVpvp
Now my json response( vm.items) ...
0
votes
1answer
17 views
unable to show c3 simple chart directives with in angularjs gridster
I am trying to show angularjs c3 charts in angular gridster. I am using c3 chart directives from https://github.com/wasilak/angular-c3-simple. Even though the gridster is appearing the charts with in ...
0
votes
2answers
23 views
How to sort by descending datetime ng-repeat in Angularjs?
I want to sort my data by descending date, ie 27, 26 , 25 .... How to do this?
<tbody class="gradeX" ng-repeat="x in Profile | orderBy: x.created_datetime">
<tr>
<td>{{x....
0
votes
1answer
32 views
Angular directive not rendering with templateUrl in ionic app
In chrome - both variants work. However, when emulating ios - the directive using templateUrl does not work.
This does not work in the ios emulator but does work in the browser:
angular.directive('...
0
votes
2answers
21 views
AngularJS access directive controller variable in directive link function
Although this question has been asked before, it is not working for me. The controller variable "myVar" is set before the link function is called. And according to docs and other posts myVar should ...
59
votes
4answers
23k views
Unit-testing directive controllers in Angular without making controller global
In Vojta Jina's excellent repository where he demonstrates testing of directives, he defines the directive controller outside of the module wrapper. See here:
https://github.com/vojtajina/ng-directive-...
14
votes
5answers
14k views
Dynamic form name attribute <input type=“text” name=“{{ variable-name }}” /> in Angularjs
How would someone use formName.inputName.$valid when the "inputName" was dynamically created?
<form name="formName">
<input ng-repeat="(variable) in variables"
type="text" ...
1
vote
0answers
17 views
Group within table angularjs
I'm relatively new to Angular but using it to build out a dynamic pivot table structure.
Here's basically what the end result is supposed to look like (sorry for poor image quality):
both the ...
0
votes
2answers
33 views
How to access directive's controller variables in directive's template?
Need to use variable (defined inside the controller element of directive) in the template element.
angular.module('home').directive('mediaTile', function(){
return {
restrict: "AE",
...
5
votes
2answers
2k views
AngularJS + Directive: Multiple Transcluded Elements
I'm trying to add a body directive which will have a left panel and a right panel. But in between these panels I will have some content that is private to the body directive. I'm currently using ...
36
votes
8answers
24k views
Using ES6 Classes as Angular 1.x directives
I'm doing a small project to play around the goody bag the ES6 is bringing, I'm trying to set register a class as an angular directive, but I'm running into this error "TypeError: Cannot call a class ...
1
vote
1answer
29 views
ng-repeat refusing to execute
I have my Javascript (Angular custom directive) as follows:
var addedSubject = function($rootScope){
return{
restrict:'E',
templateUrl:'/static/html/marks_app/directives/...
0
votes
1answer
768 views
Angularjs directive conditional rendering without ng-if
I have a directive which I render only if my authentication service tells me so:
<div my-loggedin-directive ng-if="security.isAuthenticated()"></div>
The directive itself is quite empty :...
2
votes
1answer
53 views
conditional custom attribut directive in AngularJS
I have two custom directives (restrict : 'A') which are working well (custom1 and custom2)
In my html page I would like to use either custom1 attribut or custom2 attribut on a div depending on a ...
4
votes
1answer
68 views
+50
Apply CodeMirror to a ng-model-bound textarea
I am coding a very very basic playground. For some reason, I need to embed the html panel inside an AngularJS app.
In this version, I put a JQuery change listener to the CSS panel, and applied ...
577
votes
28answers
377k views
How to set focus on input field?
What is the 'Angular way' to set focus on input field in AngularJS?
More specific requirements:
When a Modal is opened, set focus on a predefined <input> inside this Modal.
Everytime <input&...
0
votes
0answers
12 views
Angular JS + EaselJS access to canvas in Directive
I'm pretty new to AngularJS.
In my Directive i'd like to create a Element and access it via it's controller:
var app = angular.module('myApp.myDirective', []);
app.directive('myCanvas', [myCanvas]);
...
0
votes
2answers
18 views
Edit the selected option text in “ng-options” select-list
I need to add the text "(Default)" to the selected-option text. please help me...
The text should be "Visa 1881 (Default)".
But its only showing "Visa 1881". Here is my code:
<select ng-...
1
vote
2answers
40 views
how to get the scope I bind to template inside directive link
in html,i bind id inside directive:
<my-customer data="id"></my-customer>
in js:
angular.module('Main', [])
.controller('Controller', ['$scope', function($scope) {
$scope.id= 'divId'...
3
votes
1answer
346 views
Angular-masonry - expanding an item
In a nutshell, what I want to achieve using the Angular-masonry directive (http://passy.github.io/angular-masonry/) is something like this: http://codepen.io/desandro/pen/htsui
I have tried a number ...
0
votes
1answer
38 views
reload the angularjs after update , date not updated
i am working in angularjs 1.i am trying to make CRUD in angularjs and laravel.i have successfully make the CRUD and CRUD is working fine , in my application their is child and parent routing present ...
0
votes
1answer
47 views
Angularjs Data Binding among Controller, Directive, and Service
I am trying to update content of a directive with the data coming from a service. It works like this:
Service (html5 canvas service) -> calls a method in controller on some action
Controller updates $...
0
votes
1answer
19 views
AngularJS directive - initial invoke function
I use this directive:
function communicationCreateFormDirective($timeout) {
var directive = {
restrict: 'E',
scope: {
selectedCommunicationGroups: '=',
...
98
votes
7answers
54k views
Select text on input focus
I have a text input. When the input receives focus I want to select the text inside of the input.
With jQuery I'd do it this way:
<input type="text" value="test" />
$("input[type=text]")....
49
votes
5answers
85k views
Showing alert in angularjs when user leaves a page
I'm an angularjs new bee. I'm trying to write a validation which alerts the user when he tries to close the browser window.
I have 2 links on my page v1 and v2.When clicked on the links it takes to ...
2
votes
2answers
101 views
+50
AngularJS bootstrap popover custom directive
I have created a directive using bootstrap custom popover. That works taking an input from a user for a group name and it has two buttons for apply that value to model and show that value on tooltip ...
0
votes
0answers
7 views
Angular2: Property binding permission not used by any directive on an embedded template
I have create one directives in angular2. but, not working and return error template parse.
my directives :
import { Directive, Input } from '@angular/core';
import { TemplateRef, ViewContainerRef }...
0
votes
3answers
59 views
AngularJS dynamic search box on same page
I am new in AngularJS but I have basic HTML and JavaScript knowledge.
I have a list of links on page, and a search box. I want to filter list elements dynamically according to the text typed in the ...
0
votes
0answers
23 views
D3 (as AngularJS directive) - how to apply changed property of nested data object to DOM?
Situation
I have an AngularJS1 directive for my editable D3 network topology graph, consisting of nodes (<image>) and links (<line>).
Insert and deletion of nodes / links works as expected ...
0
votes
1answer
23 views
two way binding reflecting change in parent template but not in parent controller
I have created one custom directive using isolate scope for way data binding.
I am broadcasting event from parent to change one of the variable value and then binding this changed value to variable ...
1
vote
0answers
27 views
AngularJS 1.5 component get parent ngModel
I can't change ngModel defined in $ctrl. It looks like this:
1. I have next code, defining component in index.html:
<div ng-controller="appControllerData">
...
<div ng-controller="...
0
votes
0answers
10 views
Notification alert service not working in controller getting typeError: Cannot read property 'alerts' of undefined
I have capturing the application response error ,while capturing the error, i am getting the error.
In Interceptor ,according to the response code , have assign the rootscope broadcast and show the ...
0
votes
1answer
37 views
Duplicates in a repeater are not allowed?Use 'track by' expression to specify unique keys.?
I have created notification service globally for the application, while sending the db call, capturing the error code in interceptors and show alert.
how to avoid the duplicated Error mesage in ...
0
votes
1answer
48 views
how can I show a div and perform a task on ng-click Angular JS?
I have a list of users in a page and a form in which I edit the details of those users.
the form is hidden, I want to display the form when I click on edit button and also perform the task to edit it ...
1
vote
1answer
26 views
Isolate scope in Directive with TypeScript and Angular 1
I am stuck on an issue when trying to create a new angular directive using TypeScript. The issue only happens if I am planning to use the isolate scope in the directive. Following is what I am doing:
...
1
vote
4answers
31 views
why the factory is not able to access inside the controller
I have created notification factory and pass inside controller,Inside controller when assign the factory to the scope getting error.
alertsManager
MyApp.factory('alertsManager', function() {
...
37
votes
1answer
15k views
Should angular $watch be removed when scope destroyed?
Currently working on a project where we found huge memory leaks when not clearing broadcast subscriptions off destroyed scopes. The following code has fixed this:
var onFooEventBroadcast = $rootScope....
0
votes
2answers
26 views
Dynamically manipulate attribute values of Angular directive template
I have a directive in this format:
<img id="imgId" src="img/sample.jpg" border="0" width="100%" usemap="#image-maps-sample" alt="" />
<map name="image-maps-sample" id="sampleMap">
<...
2
votes
1answer
34 views
AngularJS - How to refresh directive scope
I've created a simple datepicker directive which have an "options".
So I start the datepicker with a set of options, and then because of business logic I change those options, but this are not being ...
34
votes
5answers
19k views
Angular 1.5 component vs. old directive - where is a link function?
I've been reading this nice recent article about new .component() helper in Angular 1.5, which is supposed to help everyone to migrate to Angular 2 eventually. Everything looks nice and simple, but I ...