angularjs-directive

angularjs: how to handle a popup with a directive so that data comes from controller model

家住魔仙堡 提交于 2019-12-25 07:11:59
问题 Suppose I have this tag in a template URL, into which HTML coming from the model is injected (HTML is basically <li> bullet points): <div ng-bind-html="accident.description.impact"></div> A portion of the model is as follows: "cause": "<ul>\n\ <li>\n\ <div><span inline-popover \n\ popover-html=\"Taper pour ouvrir la vue détaillée\" \n\ popover-placement=\"bottom\" \n\ popover-label=\"Larve de taupin\">Larve de taupin</span></div>\n\ </li>\n\ <li>Semences en cours de germination</li>\n\ </ul>"

How to open popover for update my record in ANgularjs

孤人 提交于 2019-12-25 07:02:18
问题 Friends, I waant to update my record using popover and i have to used angularjs directive.my popover is open but data not populated in textbox and update button click not working below my cod which i used SCRIPT : var mymodal = angular.module('mymodal', []); mymodal.controller('MainCtrl', function ($scope) { $scope.days = [{ 'ID': 1, 'name': 'Sunday' }, { 'ID': 2, 'name': 'Monday' }, { 'ID': 3, 'name': 'Tuesday' }, { 'ID': 4, 'name': 'Wednesday' }, { 'ID': 5, 'name': 'Thursday' }, { 'ID': 6,

has-authority not working on a button

亡梦爱人 提交于 2019-12-25 06:51:08
问题 So I used JHipster to generate my app. I could see the navbar using the has-authority directive to show/hide menus. Now what I would to do is to use the directive on a button to show it only to users with ROLE_ADMIN here's the code of the directive .directive('hasAuthority', ['Principal', function (Principal) { return { restrict: 'A', link: function (scope, element, attrs) { var setVisible = function () { element.removeClass('hidden'); }, setHidden = function () { element.addClass('hidden');

how to access object property via isolate scope without two-way binding?

只愿长相守 提交于 2019-12-25 06:25:13
问题 I want to pass a product's id to a directive like so: <widget product-id="product.id"></widget> I prefer not to use curly braces: <widget product-id="{{product.id}}"></widget> because it's more verbose, and I want to match the style of ng-model usage. I want to use isolate scope so that I can't accidentally modify product.id inside the widget. If I use: scope { productId: '@' } Then in my directive template: {{productId}} gives me the string "product.id" If I use: scope { productId: '&' } I

angularjs passing parameters through directive and ng-repeat

纵饮孤独 提交于 2019-12-25 06:15:14
问题 Let's try again: here's a working plunker: http://plnkr.co/edit/RTrdsLY8ONoeDLPYSFJi?p=preview But the fields are connected each other. when you look at DOM: <input class="form-control ng-pristine ng-valid-maxlength ng-valid-minlength ng-valid ng-valid-required" type="text" name="fieldName" ng-model="fieldName" ng-minlength="3" ng-maxlength="20" required=""> ^^^^^^^^^^ of course! All have name="fieldName"! But why!? it should be first_name, last_name and age! Yes, there's a mistake in

Angularjs custom validation directive Async call real time validation

不问归期 提交于 2019-12-25 06:05:07
问题 I am using custom validation directive to validate a field in a form and the validation process includes a AJAX call to verify user information with server API. We want to validate the field as long as user stops typing for a certain period of time. I have two questions: 1.Why is the function below not working?(with link function in the custom directive) The log message was never shown no matter how many times I type in the binded input field (I am pretty sure I enabled log message display

Pass parameter to Angularjs controller function from directive

别等时光非礼了梦想. 提交于 2019-12-25 06:01:09
问题 I have a AngularJs directive that creates a property and callback function on its isolated scope: .directive('testButton', [function () { return { restrict: 'A', controller: 'TestDirectiveController as vmDirective', scope: { myCallBack:'&myCallBack', myVariable: '=myVariable' }, template: function (element, attrs) { return '<button data-ng-click="vmDirective.onButtonClicked(2)">Set myVariable = 2</button>'; } };}]) In the directive a button gets clicked and it executes the onButtonClicked

Custom validation directive using ng messages and typescript

半腔热情 提交于 2019-12-25 05:48:26
问题 I'm trying to build a module that has directive for custom validations and showing them using ng-messages The validations are done via regex. The error I am seeing is : Error: [$compile:ctreq] Controller 'ngMessages', required by directive 'ngMessage', can't be found! My code looks like this: Validation directive: module LoginModule { 'use strict'; /***** REGEX *****/ export class regExp { public ID_OR_PASSPORT = /^[0-9]{9}$/; public USERNAME_SINGLE_WORD = /^[A-Za-z0-9à-ú-_\.]{6,8}$/; public

Zero watchers in directive if one-time binding is used in angular 1.3+

旧时模样 提交于 2019-12-25 05:43:12
问题 I have made a user-name directive for this question .directive('userName', function($http) { return { restrict: 'E', scope: { user: '=' }, replace: true, template: '<div><span ng-bind="user.username"></span> <a ng-if="user.active">Add</a></div>', }; }); It is important that the directive uses a minimal number of watches when I use one-time binding af the user attribute ( <user-name user="::user"></user-name> ). I have a number of questions. I have created this plunker to test my directive.

How share Service dynamic data between Controllers and Directives

烂漫一生 提交于 2019-12-25 05:27:22
问题 I'd like to know what pattern to use, if I need my Service to share it's dynamic data between Controller, Directives, etc. The reason I mention dynamic, is because I'd like to load new data and this data needs to be available in any other Controller, Directive, etc. For example, if a Directive generates a UL LI, it would have to re-generate it if the data inside the Service has changed! I've initially opened the following ( How to create reset() method in Service that return promise? ) and