Search Posts

Category: angular-directive

AngularJS – conditional rendering

I’m trying to render form elements (select/input) which are dynamic. I have a list of fields with their types. Here is the html part: <tr ng-repeat=”f in leistung.Fields”> <td class=”data”>{{fieldsMap[f.InternalName].Title}}</td> <td class=”dataEdit”> <input ng-if=”fieldsMap[f.InternalName].Type != ‘DateTime’ && fieldsMap[f.InternalName].Type != ‘Choice’ && fieldsMap[f.InternalName].Type != ‘Lookup'” type=”text” class=”ms-long” ng-model=”values[f.InternalName]”/> <div ng-if=”fieldsMap[f.InternalName].Type == ‘DateTime'”> <input type=”text” class=”borderRight” ng-model=”values[f.InternalName]”/> <a href=”javascript:” ng-click=”selectDate()” onclick=”return false;”> <img src=”/_layouts/15/images/calendar_25.gif” border=”0″ alt=”Wählen Sie im Kalender ein Datum aus.” style=”vertical-align: middle;” title=”Wählen Sie im […]

How to access the attributes inside change function

Inside the change function I want to use the attrs. Outside of change attrs are available but inside the change attrs are not available. app.directive(‘uploadFile’,[‘documentService’,function(documentService){ return { restrict: ‘AE’, link : function($scope,element,attrs){ element.on(‘click’,function(e){ // here I want to access the attrs. }) } } }]); html:- <button upload-file=”selectedDocumentName,FolderNumber” ><!– ng-click=”uploadFile(selectedDocumentName,FolderNumber)” –> Source: AngularJS

how to get arguments in directive

I have a button and when I click on that function I need to call a directive. For this I have writern the following code.before creating directive there is a ng-change function.I have removed ng-change and kept directive as follows, <button upload-file=”selectedDocumentName,loanFolderNumber” ><!– ng-click=”uploadFile(selectedDocumentName,FolderNumber)” –> How can I take that arguments selectedDocumentName,FolderNumber in my directive.I have tried in the following way,but I am not getting the values. Directive:- app.directive(‘uploadFile’,[‘documentService’,function(documentService){ return { restrict: ‘AE’, scope: { […]

How to get ng-model value to directive

in the following directive I need ng-model value. app.directive(‘getRelatedDocumentDetails’,[‘documentService’,function(documentService){ return { require: ‘ngModel’, restrict: ‘AE’, //attribute or element replace: true, link: function(scope,element,attrs,ngModel){ element.on(‘change’,function(element,attrs){ //Here I need ng-model }) } } In the above code I am not getting ng-model inside the change function. Source: AngularJS

How to remove a selected value in autocomplete dropdown in angularJS (1.x)?

In angularjs autocomplete list having multiple options like pincode, temperature, humidity, latitude, longitude. If I select pincode, I need to remove pincode from the list. If I remove selected option pincode again, then I need to add pincode in options. Looking for positive response. Thank you. My html code: <md-chips flex ng-if=”widgetType != types.widgetType.alarm.value” id=”timeseries_datakey_chips” ng-required=”true” ng-model=”timeseriesDataKeys” md-autocomplete-snap md-transform-chip=”transformTimeseriesDataKeyChip($chip)” md-require-match=”false”> <md-autocomplete md-no-cache=”true” id=”timeseries_datakey” md-selected-item=”selectedTimeseriesDataKey” md-search-text=”timeseriesDataKeySearchText” md-items=”item in dataKeysSearch(timeseriesDataKeySearchText, types.dataKeyType.timeseries)” md-item-text=”” md-min-length=”0″ placeholder=”timeseries” md-menu-class=”tb-timeseries-datakey-autocomplete”> <span md-highlight-text=”timeseriesDataKeySearchText” […]

Why is my AngularJS directive caching previous values?

I have implemented “navbar” in my web application using AngularJS directive. When the user is logged in, it displays the username of the logged in user. But, when I log in as a different user, it still displays the username of the previous user until I manually refresh the window. Is there any solution to this? This is the navigation-directive.html <header class=”container” ng-controller=”HomeController as vm” ng-init=”vm.init()”> <!– Fixed navbar –> <nav class=”navbar navbar-expand-md navbar-dark fixed-top […]

Alternative for broadcast and emit in angularjs even without using services

Is there any alternative for broadcast and emit, because my screen has multiple popups.if i am selecting a value in popup it should be populated in the respective field.For this I am using broadcast when the value is selected in popup.So it is not only populated in the respective field but also other fields which has this broadcast listner($on). If I am going for services to set data while the value is selected.That is fine. […]

Why is Directive’s link function runs after $timeout

Why is $timeout running before directive render. Here is my directive angular.module(‘directiveTestModule’).directive(‘popupMessage’, [‘$filter’, ‘crudService’, ‘serviceConfiguration’, ‘$rootScope’, ‘$timeout’,’$parse’, function ($filter, crudService, serviceConfiguration, $rootScope, $timeout, $parse) { return { restrict: ‘E’, replace: true, scope: { instance:’=instance’, options: ‘=options’ }, replace: true, templateUrl: ‘Scripts/app/shared/popupMessage/popupMessageView.html’, controller: function ($scope, $element) { }, link: function ($scope, $element, attr) { //$scope.instance = $parse(attr[‘popupMessage’])($scope) || {}; $scope.instance = {}; $scope.instance.showMessage = function () { alert($ } } } }]); And here is the […]

Next Page »