angularjs-directive

why “<ng-container> not working in ”<tr>\" tag

丶灬走出姿态 提交于 2019-12-06 10:45:32
Code: <table> <tr> <ng-container ng-if="false"> // here ng-container not working <td> <ng-container ng-if="false">abc</ng-container>// here ng-container working fine </td> <td><ng-container ng-if="true">xyz</ng-container></td> </ng-container> </tr> </table> OutPut: xyz here expected output is no one cell was display but in between <tr> and <td> tags <ng-container ng-if="false"> are not working. If anyone idea about this problem please get solution. I analysis this issue in deep and i faced some situation like <ng-container ng-if=""> or <ng-container ng-show=""> or <ng-container ng-hide="">

How to load dynamic inline template with angular

狂风中的少年 提交于 2019-12-06 10:21:00
I have an ng-repeat that loops over an array of objects. At each loop the value 'template' & 'values' is initialised. The following version works and uses ng-include to load the template but it happens to be very very slow: <tr class="tableRowsDocs" ng-repeat="dbo in rows track by $index"> <div ng-init="values = dbo.get4(attobj.key); key = attobj.key; template = attobj.template || getAttributeTemplate(dbo.clazz + attobj.key);"> <div class="content" ng-include="template"></div> </div> </td> </tr> The value for template and values is dynamic but it always holds the id of a template/script like:

How to set default date in datetimepicker with ngmodel?

本秂侑毒 提交于 2019-12-06 10:06:22
I've created this angular directive that wraps a jQuery plugin datetimepicker. How can I get the default dates defined in the controller to display as the default date in the controls? http://jsfiddle.net/edwardtanguay/ef1o3c95/5 I've tried a number of variations with ngModel.$viewValue but can't get the yyyy-mm-dd text to simply display in the control. <div ng-controller="mainController"> <div class="form-group"> <div class='input-group date' timepicker ng-model="date1"> <input type='text' class="form-control" /> <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"><

Unit Test Expect SpyOn Not Found

五迷三道 提交于 2019-12-06 09:57:55
I have a directive (restrict A) that handles an event click, and calls a service based on a value. Directive: define(function () { 'use strict'; var myDirective = function ($rootScope, myFactory) { return { restrict: 'A', scope: { _myValue : '=value' }, link: function(scope, element, attrs) { element.bind('click', function() { if (scope._myValue === 'red') { myFactory.red(); } if (scope._myValue === 'green') { myFactory.green(); } if (scope._myValue === 'black') { myFactory.black(); } }); } }; }; return ['$rootScope', 'myFactory', myDirective]; }); Test: define(['angular-mocks'], function () {

Create a container directive in angularjs

老子叫甜甜 提交于 2019-12-06 09:57:41
问题 So I'm trying to create a directive that will layout a collection of items in columns. In the plunker I have a extremely simplified version which only uses a single ul, but that is not important. I want the directive to be called like . <my-column-layout collection="names"> <tab name="{{ item }}"></tab> </my-column-layout> I want to use the inner html (the tab here) as a template for each item in the collection. I tried to just have a ng-repeat in the my-column-layout template like template :

AngularJS : How to transclude and have both isolate scope and parent scope?

爷,独闯天下 提交于 2019-12-06 09:38:47
I have a pattern wherein many item types are "editable". This means that I have lots of templates (one for each editable item type) that expect to have unique fields, but common functions (edit, save, cancel edit, delete, etc.). These common functions lead to lots of repetition on controllers: save , edit , cancel , etc., and very repetitive error-handling. One way I looked at of dealing with this was to have each controller "decorate" itself (using a service), but it got messy as well. I prefer a directive, say, 'editable': <form name="editGroup" editable> <div ng-show="editMode"> <!-- lots

How to check if a component exists in Angular 1.5

给你一囗甜甜゛ 提交于 2019-12-06 09:26:28
http://embed.plnkr.co/oGlcQSOM2vFcDEKP7thV/ $injector.has('myMessageDirective') returns true, while $injector.has('myMessageComponent') does not Is anyone struggling with this or has a solution? My "fear" is that my components might not be found in future updates because of the directive check. Follow up question to: Check if an Angular directive exists At the end of the day, a component is registered as a directive, so 'Directive' suffix is indeed needed. Check 'has' method of $injector object: return { invoke: invoke, instantiate: instantiate, get: getService, annotate: createInjector.$

Display pdf inside an ionic app

痴心易碎 提交于 2019-12-06 09:06:29
问题 Im developing an app with ionic framework and I need to display a pdf. I've read a lot on the internet and found this directive to use https://github.com/winkerVSbecks/angular-pdf-viewer The problem is that I'm having problems to integrate the directive with my ionic app. I've done the indicated steps: bower install angular-pdf-viewer Include the path to the lib, AngularJS and PDFJS: (here I changed the paths) <script src="lib/pdfjs-dist/build/pdf.js"></script> <script src="lib/angular

Why isn't my directive's selection being bound to the controller?

孤街醉人 提交于 2019-12-06 08:59:13
问题 I've got a very simple directive I'm working with - it's a small wrapper around a dropdown. I want to expose an attribute, "selectedOption" (well, selected-option) from it that I can two-way bind to the controller. I've set the property in the scope of the directive (and set it to = which I thought would allow the two-way binding), then exposed a property on the main controller. I've attached an example. I would have expected that the default item shown would be "Beta". And if I changed

What is the main use of transclusion in angularjs

对着背影说爱祢 提交于 2019-12-06 08:47:30
问题 I have recently come across transclusion in directives, what is the purpose of having this concept. As far as I know its encapsulation of an object and have 2-way binding possibly. But this can be possible by using '=' in the scope attribute in directive. So whats the big deal about directive? 回答1: Transclude allows : To create directives that wrap other elements. To clone the same transcluded contents multiple times. To re-clone the trancluded contents when an event occurs. ngTransclude and