angularjs-directive

Compare two fields in angularjs directive

≡放荡痞女 提交于 2019-12-05 15:21:58
I am trying to create directive which can be used to compare two fields in multiple projects. MarkUp : <div class="form-group"> <input ng-model="user.password" type="password" name="password" /> </div> <div class="form-group"> <input ng-model="user.confpassword" ng-compare="password" name="confpassword" type="password" /> <p ng-show="registrationform.password.$error.ngcompare" class="help-block">Password's don't match</p> Directive : "use strict"; angular.module('app.directive.ngCompare', []).directive('ngCompare', function () { return { require: 'ngModel', link: function (scope, element,

Applying angular2 form directives to custom input form elements

百般思念 提交于 2019-12-05 14:34:57
I want to create a custom InputCustom component and use it to create model-driven forms. My custom component just wraps an input field and uses Bootstrap material design for look'n'feel. @Component({ selector:'inputCustom', template:` <div class="form-group label-floating is-empty"> <label class="control-label" for="input">Type here</label> <input class="form-control" id="input" type="text"> <p class="help-block">Some help text</p> <span class="material-input"></span> </div> `}) class InputCustom{....} In Angular2 when you create a model-driven form <form [ngFormModel]="formRef"> <input type =

How to render html formatted content in ng-grid?

ⅰ亾dé卋堺 提交于 2019-12-05 13:57:18
I have jsonData which consist of HTML content. I want to render that HTML in ng-grid. The content is not rendered however -- it only shows up in normal string format. Below is the plnkr which shows all the code: http://plnkr.co/edit/RlWyDqCUUR15dmLM7ePV?p=preview There's a few things going on here: Not related to your exact issue, but you've got nested single quotes in your firstName field. You need to do some escaping or your ng-click expression is going to break. So instead of ng-click='show('F:/cox/main.html')' you can do ng-click=\"show('F:/cox/main.html')\" . Also not related to your

Detach then append AngularJS form change validity status

我怕爱的太早我们不能终老 提交于 2019-12-05 13:25:13
You can test it in this jsFiddle: HERE (better is to see on new jsFiddle, see EDIT part of this post) I think there is a bug in AngularJS or at least not an expected result. If i detach a form then re-append it, it's class ng-invalid switch to ng-valid on re-append it to the DOM. This has for consequence to enable the submit button of the form even data aren't valid. Of course, i was expecting that validity status didn't switch. I think it's a angular bug, but maybe a jquery one. I could use jquery to check on append if form was valid or not and then forcing form class but it's seems not

What is the difference between an ng-controller directive and a controller in the route?

牧云@^-^@ 提交于 2019-12-05 13:22:56
问题 I worked through the tutorial on the AngularJS website and I noticed that in at step 7, they change how a controller is introduced into the application. Initially, they use a directive: <body ng-controller="PhoneListCtrl"> ... </body> However, it later gets changed to use a controller attribute as part of an ng-route . $routeProvider. when('/phones', { templateUrl: 'partials/phone-list.html', controller: 'PhoneListCtrl' }). /* rest of routes here */ Here's the git diff where the change is

AngularJS Directive Value

浪子不回头ぞ 提交于 2019-12-05 13:06:47
问题 I have an AngularJS directive. My directive is restricted to be used as an attribute. However, I want to get the value of the attribute. Currently, I have my attribute defined as: angular.module('myDirectives.color', []) .directive('setColor', function () { return { retrict: 'A', link: { pre: function () { console.log('color is: '); } } }; }) ; I use the attribute in the following manner: <button type="button" set-color="blue">Blue</button> <button type="button" set-color="yellow">Yellow<

Setting attribute value of an element in camelCase using a directive

 ̄綄美尐妖づ 提交于 2019-12-05 12:55:43
I'm trying to add an attribute to an angularJs element from a directive like this: element.attr('startOffset', val); But when I check the element, the attribute added is 'startoffset' where the 'o' is not a capital letter. Is there any way to add an attribute to an element and keep the case of the word intact? Thanks If you set an attribute using jqliteWrapper .attr or even with direct DOM operation .setAttribute it will lowercase the attribute name, before attaching to the element. When called on an HTML element in an HTML document, setAttribute lower-cases its attribute name argument. Since

Bitwise operation inside angular ng-if

余生长醉 提交于 2019-12-05 12:54:56
I want to load different templates for different screen sizes in a particular view. Markup : <div id="phoneMetaDiv" class="visible-xs"><!-- Visible on phones --></div> <div id="tabletMetaDiv" class="visible-sm"><!-- Visible on tablets --></div> <div id="desktopMetaDiv" class="visible-md"><!-- Visible on desktops --></div> <div id="giantScrMetaDiv" class="visible-lg"><!-- Visible on giant screens --></div> App script: app.run(function ($rootScope) { $rootScope.Views = { Phone : 1, //0001 Tablet : 2, //0010 Desktop : 4, //0100 GiantScr: 8, //1000 }; if($("#giantScrMetaDiv").is(":visible"))

How to remove index.html from url on website based on angularjs

♀尐吖头ヾ 提交于 2019-12-05 12:48:44
问题 I didn't find a way to remove index.html from the url, because like this looks really ugly. mydomain.com/index.html#/myview1 mydomain.com/index.html#/myview2 Is there a way to remove that part, like that url will be so clear where the user is. mydomain.com/myview1 mydomain.com/myview2 Tnx in advance for your time. Edit: I just find way that it could work like: mydomain.com/#/myview1 mydomain.com/#/myview2 which is pretty much better then with index.html. But still if there is a way for

AngularJS - Create a directive that adds a sibling element

◇◆丶佛笑我妖孽 提交于 2019-12-05 12:11:24
I'm creating a my-validate directive that looks something like this <input my-validate="customValidation" ng-model="model" /> What I want to do is to attach a sybling element to the directive like this Error template: <ul class"errors"> <li ng-repeat="for error in errors">{{error}} not valid</li> </ul> errors is defined in the scope of the directive. I've added the error template in the compile function, but the problem I have is that the scope in the link function is not the same as the attached template. Here is a plunker to illustrate the issue: http://plnkr.co/edit/ghdtdYruQaaO0Yxxlrt1?p