directive

Angular 2 error- There is no directive with “exportAs” set to “ngModel” with RC4 version

匿名 (未验证) 提交于 2019-12-03 02:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using angular 2 forms in my application and i have created the forms based on given link. https://angular.io/docs/ts/latest/guide/forms.html In this for validation and to use forms APIs, i have set the ngModel values like #name="id" #id="ngModel" and which throws script error. But its resolved if i set #id="ngModel" as #id="ngForm" . But for my case i have to set my model value to ngModel . Below is my html page. <form (ngSubmit)="onSubmit()" #myForm="ngForm"> <div class="form-group"> <label class="control-label" for="id">Employee ID<

Multiple directives asking for templates on

匿名 (未验证) 提交于 2019-12-03 02:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following HTML: <div style="border:1px solid; height:300px; width:500px; position:relative; left:100px" id="canvas"> <tbox ng-repeat="tb in textBoxes" ng-model="tb"> </tbox> </div> And the following 2 directives appModule.directive('resizable', function($compile, $document) { return { restrict: "A", template: '<div ng-style="{top:tb.x, left:tb.y, height:tb.height, width:tb.width}" ng-transclude><span class="scale">s</span></div>', transclude: true, replace: true, require: 'ngModel' } }); appModule.directive('tbox', function(

Use an angular directive inside another directive

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have created the below angular directives, ChildDirective that is used inside ParentDirective var wizardModule = angular.module('Wizard', []); wizardModule.directive('childDirective', function ($http, $templateCache, $compile, $parse) { return { restrict: 'E', scope: [], compile: function (iElement, iAttrs, transclude) { iElement.append('child directive<br />'); } } }) wizardModule.directive('parentDirective', function ($http, $compile) { return { restrict: 'E', compile: function (element, attrs) { var x = '<child-directive></child

angularjs: custom directive to check if a username exists

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have my registration form with textbox username. I want to do is when the user enter the username, the custom directive will check if the entered username is exists in the database. directives.js angular . module ( 'installApp' ). directive ( 'pwCheck' , function ( $http ) { return { require : 'ngModel' , link : function ( scope , elem , attrs , ctrl ) { elem . on ( 'blur' , function ( evt ) { scope . $apply ( function () { $http ({ method : 'GET' , url : '../api/v1/users' , data : { username : elem . val (), dbField : attrs .

Extending Angular Directive

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'd like to make a minor modification to a 3rd party directive (specifically Angular UI Bootstrap ). I simply want to add to the scope of the pane directive: angular.module('ui.bootstrap.tabs', []) .controller('TabsController', ['$scope', '$element', function($scope, $element) { // various methods }]) .directive('tabs', function() { return { // etc... }; }) .directive('pane', ['$parse', function($parse) { return { require: '^tabs', restrict: 'EA', transclude: true, scope:{ heading:'@', disabled:'@' // <- ADDED SCOPE PROPERTY HERE }, link:

Sending event when angular.js finished loading

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Wondered what's the best way to detect the finish of page loading/bootstrapping, when all directives done compiling/linking. Any event already there? Should i overload the bootstrap function? 回答1: Just a hunch: why not look at how the ngCloak directive does it? Clearly the ngCloak directive manages to show content after things have loaded. I bet looking at ngCloak will lead to the exact answer... EDIT 1 hour later: Ok, well, I looked at ngCloak and it's really short. What this obviously implies is that the compile function won't get executed

Custom form validation directive to compare two fields

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm an angular newbie, and I'm stumbling over something in how angular's form validation directives work. I know that I can fairly easily add directives to individual fields , but I'm trying to add a validation which will compare two form fields (both of which are elements of a model). Here's a form skeleton: <form name="edit_form" > <input name="min" type="number" ng-model="field.min"/> <input name="max" type="number" ng-model="field.max"/> </form> <div class="error" ng-show="edit_form.min.$dirty || edit_form.max.$dirty"> <small class=

model.$modelValue is NaN in directive

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: See this jsfiddle: http://jsfiddle.net/8bENp/66/ If you look at the JavaScript console, you'll see something like this: TypeError: Object NaN has no method 'replace' at makeHtml (https://raw.github.com/coreyti/showdown/master/compressed/showdown.js:62:705) at render (http://fiddle.jshell.net/_display/:50:42) at link (http://fiddle.jshell.net/_display/:54:13) at k (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js:42:321) at e (https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js:38:198) at k (https://ajax

Decorating the ng-click directive in AngularJs

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've been looking into modifying the AngularJS ng-click directive to add some additional features. I have a few different ideas of what to use it for, but a simple one is to add Google Analytics tracking to all ng-clicks, another is to prevent double clicking. To do this my first thought was to use a decorator. So something like this: app . config ([ '$provide' , function ( $provide ) { $provide . decorator ( 'ngClickDirective' , [ '$delegate' , function ( $delegate ) { // Trigger Google Analytics tracking here return $delegate ; }

AngularJS directive does not update on scope variable changes

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've tried to write a small directive, to wrap its contents with another template file. This code: My cool content Should have this output: My cool content Because the layout "Default" has this code: {{content}} Here the code of the directive: app.directive('layout', function($http, $compile){ return { restrict: 'E', link: function(scope, element, attributes) { var layoutName = (angular.isDefined(attributes.name)) ? attributes.name : 'Default'; $http.get(scope.constants.pathLayouts + layoutName + '.html') .success(function(layout){ var