angularjs-directive

How to use a keypress event in AngularJS?

白昼怎懂夜的黑 提交于 2019-12-27 09:01:22
问题 I want to catch the enter key press event on the textbox below. To make it more clear I am using a ng-repeat to populate the tbody. Here is the HTML: <td><input type="number" id="closeqty{{$index}}" class="pagination-right closefield" data-ng-model="closeqtymodel" data-ng-change="change($index)" required placeholder="{{item.closeMeasure}}" /></td> This is my module: angular.module('components', ['ngResource']); I am using a resource to populate the table and my controller code is: function

Angular directive templateURL not being loaded. Why? [closed]

允我心安 提交于 2019-12-27 07:29:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I've created a directive in Angular. The directive 'compiles' when I use the template attribute. It doesn't compile in when using templateURL . The templateURL file doesn't 404 in angular page's console or network tab. It is 200 as a browser URL. What am I missing? 'use strict'; angular.module('mean.profile')

Angular directive templateURL not being loaded. Why? [closed]

喜你入骨 提交于 2019-12-27 07:24:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I've created a directive in Angular. The directive 'compiles' when I use the template attribute. It doesn't compile in when using templateURL . The templateURL file doesn't 404 in angular page's console or network tab. It is 200 as a browser URL. What am I missing? 'use strict'; angular.module('mean.profile')

AngularJS - how to use ng-required only for active fields

假如想象 提交于 2019-12-25 19:02:50
问题 I have an application where toggle button is, and when clicked, it activates fields for user input. Fields are on one page, button is calling like this: <span ng-include="'partials/triggers/toggleButton.html'"></span> <a ng-click="toggle()"> <span class="glyphicon" ng-class="{'glyphicon-ban-circle': t.active, 'glyphicon-ok-circle': !t.active}"></span> </a> <div ng-controller="TriggerController" ng-init="init(relay, 'inactiveFor')"> <fieldset class="form-group sentinel-line" ng-disabled="!t

Convert number to currency through directive

爷,独闯天下 提交于 2019-12-25 18:52:10
问题 I am trying to convert number into currency suppose if user enter 5 in textbox i want to auto correct it like $5.00 for that i am trying to write directive but no idea how to make it work as working on directive for fist time. (function () { 'use strict'; angular.module('commonModule') .directive('srCurreny', function (utilSvc) { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, model) { element.bind('blur', function (event) { var val = element.val(); if (

Convert number to currency through directive

痴心易碎 提交于 2019-12-25 18:51:24
问题 I am trying to convert number into currency suppose if user enter 5 in textbox i want to auto correct it like $5.00 for that i am trying to write directive but no idea how to make it work as working on directive for fist time. (function () { 'use strict'; angular.module('commonModule') .directive('srCurreny', function (utilSvc) { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, model) { element.bind('blur', function (event) { var val = element.val(); if (

AngularJS directive with two-way binding and ng-change

匆匆过客 提交于 2019-12-25 16:00:29
问题 I have come across a situation where I need to change the input type of an input box based on the selected value of a dropdown. In other words, if the user selects 'String' from the dropdown then the type of the input should be 'text', etc. I decided to create a directive cuz I'm still learning Angular but also so I don't copy blocks of code all over the place (I need this more than once). This it the contents of my attempt: (function () { "use strict"; angular .module('app') .directive(

Angular upload file directive

安稳与你 提交于 2019-12-25 14:45:16
问题 I need a directive for upload file (brwose to choose file, and get it as binary data ) , in my angular application. I use it a lot of times, so it has to be generic. What is the best way to do it? 回答1: https://github.com/flowjs/ng-flow This works fine.Of course some wrapping directive can be made at your side. 回答2: directive code .directive("fileReaderGallery", ['background', function (background) { return { restrict: "E", scope: true, templateUrl: "templates/directive.html", replace: true,

AngularJS & Typescript - Add a customised $validators

不羁岁月 提交于 2019-12-25 14:14:33
问题 I've created the following dummy directive with typescript : export class Room implements ng.IDirective{ public restrict = 'A'; public require = 'ngModel'; public static DirectoryName = "room"; public link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl : IRoomValidation) => { ctrl.$validators.room = function(modelValue, viewValue) { var ROOM_REGEXP = /^\w+$/; if (ctrl.$isEmpty(modelValue)) { // consider empty models to be valid return true; } if (ROOM_REGEXP

AngularJS & Typescript - Add a customised $validators

浪子不回头ぞ 提交于 2019-12-25 14:14:08
问题 I've created the following dummy directive with typescript : export class Room implements ng.IDirective{ public restrict = 'A'; public require = 'ngModel'; public static DirectoryName = "room"; public link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, ctrl : IRoomValidation) => { ctrl.$validators.room = function(modelValue, viewValue) { var ROOM_REGEXP = /^\w+$/; if (ctrl.$isEmpty(modelValue)) { // consider empty models to be valid return true; } if (ROOM_REGEXP