Search Posts

Category: directive

Ng change in directive is too slow ? why

Hi I am facing a hard time trying to findout why my directive is calling the ngChange function so slow. Without template it works super fast. Here is my Html Directive Template <input type=”search” class=”search_input artist-job-search-input” placeholder=”Search jobs by profession, musical work, role or institution” ng-model=”$ctrl.artistSearchModel” ng-change=”$ctrl.searchArtistJob()” ng-model-options=”{debounce: 500}” select-on-click style=”max-width: 55.9vw;”/> Here is directive.js app.directive(‘jobsSearch’, function () { return { restrict: ‘EA’, scope: { ‘artistSearchModel’: “=”, ‘showDropdown’: “=”, ‘operaticRoleSearchResult’: “=”, ‘viewAllJobs’: “&”, ‘musicalWorkSearchResult’: “=”, […]

AngularJS DirPagination – ng-repeat not working when a directive is clicked

I’m new to AngularJS and I’m using a plugin for Angular called ‘dirPagination‘, I have a dynamically created table and I have to append an ng-repeat row using jquery when my display-article-div-directive is clicked. Please see my code I have removed some codes to make it shorter and simpler, a sample code would be highly appreciated, Thank You, This is my dynamically created table with a dir-pagination-controls directive and display-article-div-directive PageController.js (function(elbsApp){ “use strict”; /*—————————–*/ […]

Call directive controller methods from outside

i write a directive that provide a tab functionality, i use latest version of angularjs (v1). In my directive i have a controller that expose an api to a children directives, the scope is isolated in all directives. : Parent Directive scope: {}, controller: function($scope) { $scope.values = []; this.addValue = function(value) { $scope.values.push(value); } } Child Directive on link function scope: {}, transclude: true, template: ‘<div ng-transclude></div>’, replace: true, link: function(scope, element, attr, parentCtrl) […]

how to give controller a name in a directive in Angular

So it might be a simple question. I have a directive defined this way: angular .module(‘ui-abc’, [ ‘xyz’]) .directive(‘computer’, compute); function compute( item) { return { restrict: “EA”, templateUrl: ‘../elements/src/template.html’, scope:{ qwerty : ‘=’,} controller: [‘$scope’,’$sce’, { ……… } The controller does not have a name, how can i add one ? I need this name so that I can refer to that controller inside my ui-router configuration. I tried to do this function compute( […]

Angular4: Create a Directive to Show a Profile card on Hover

For reference you can visit Twitter and hover a Profile name. That is what i’m trying to achieve. The Hover card does show correctly, But i’ve to add the ng-template each and everywhere I’ve to have this feature <div profilePeek class=”user-name cursor” (click)=”redirectProfile(item.type,”>{{ getProfileData(item.type, }} <ng-template #preview> <app-hover-profile [type]=”item.type” [key]=””></app-hover-profile> </ng-template> </div> Can this be included in the Directive as well. Im pretty new to directives, so please guide if this is a blunder. […]

AngularJS SET service variable in controller, and use GET it everywhere else without $watch

Here is my basic service to SET and GET the value: .service(‘companyService’, [ function () { var self = this self.options = {} function CompanyService () { self.setOptions = function (newObj) { self.options = newObj } } return CompanyService() }]) In the global controller I call my $api factory which makes an http request (with promise) to get and set Company Options. I do this only once. .controller(‘global’, [‘$scope’, ‘$http’, ‘$api’, ‘$location’, ‘$translate’, ‘$rootScope’, ‘$timeout’, […]