angularjs-directive

Parent directive controller undefined when passing to child directive

匆匆过客 提交于 2019-12-02 20:02:36
问题 I asked general question here in this post. I've got answer with working example; however when I try to use this example to modify existing code, I get error. See my code below and in this Plunker page. Html <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.3/angular.min.js"></script> <div ng-app="myApp"> <tmp-menu ng-disabled="true"> <tmp-menu-link></tmp-menu-link> <tmp-menu-link></tmp-menu-link> </tmp-menu> </div> JavaScript(AngularJS): angular.module('myApp', [])

Can anyone explain me this password match directive?

▼魔方 西西 提交于 2019-12-02 19:35:24
问题 Can anyone explain me on how this piece of code works. HTML Markup <input type="password" ng-model="password" class="form-control" placeholder="Password" required> <input type="password" ng-model="confirm_password" class="form-control" placeholder="Password" required validate-equals="password"> Directive Code 'use strict'; angular.module('raJwtApp') .directive('validateEquals', function () { return { require: "ngModel", link: function postLink(scope, element, attrs, ngModelCtrl) { function

AngularJS Directive: How do I hide the alert using timeout?

情到浓时终转凉″ 提交于 2019-12-02 19:33:20
Yesterday, I started writing a notification directive for my project I asked question on stackoverflow AngularJS: Alerts not showing up and after struggling through documents and videos , I am able to build a basic notification directive http://plnkr.co/edit/uqSB1gIz6XEmJfC8zHNb?p=preview What I want? Like any other app, when alerts show up, they hide after a second or so, I am trying to find out a way to hide the alert after a second, but not sure how to do that Any help is greatly appreciated UPDATE As per @Derek's answer, I am able to implement timeout http://plnkr.co/edit

Modifying DOM (slideDown/slideUp) with AngularJS and jQuery

旧时模样 提交于 2019-12-02 19:09:02
I'm trying to implement a slideDown/slideUp animation with AngularJS. I can't use CSS3's transition (unfortunately) since the height is set to auto (and I don't want to use the max-height workaround ), so I'm trying to use jQuery's slideToggle method. Given the following markup: <ul> <li ng-repeat="entry in data"> <span>{{entry.title}}</span> <a ng-click="clicked($event)" href>more?</a> <p>{{entry.description}}</p> </li> </ul> I implemented the following method in my controller: $scope.clicked = function($event) { var a = jQuery($event.target); var p = a.next(); p.slideToggle(); }; FIDDLE Even

Why does the directive ng-href need {{}} while other directives don't?

二次信任 提交于 2019-12-02 19:04:35
I am just wondering why I need to add double curly braces for ng-href while some of the other directives don't need them? <a ng-href="{{myScopeVar}}" ng-if="myScopeVar">link</a> Notice that ng-href needs braces while ng-if doesn't. michael I am not quite sure about your question. But i think your are wondering why there are different syntax styles in angular directives. First off all, please have a look at this post: Difference between double and single curly brace in angular JS? The answer explains the difference between {{}} , {} and no braces. For your concrete examples, as in the

How to get paragraph data in textarea in angularjs?

拥有回忆 提交于 2019-12-02 19:04:12
问题 how can I get paragraph content text in textarea value <p ng-model="extrap" >Some parragraph content</p> <textarea ng-model="oneps"></textarea> <script> (function() { angular .module("TextAngularDemo", ['textAngular']) .controller("DemoController", ['$scope', 'textAngularManager', DemoController]); function DemoController($scope, textAngularManager) { $scope.oneps = {{extrap}} }; })(); </script> I want paragraph text in textarea box with prefilled paragraph text 回答1: I think you need to load

How to pass HTML to angular directive?

为君一笑 提交于 2019-12-02 19:04:11
I am trying to create an angular directive with a template, but I also don't want to lose the HTML inside of the div. For example, here is how I would like to call my directive from HTML: <div my-dir> <div class="contents-i-want-to-keep"></div> </div> Then, there is my directive: app.directive('myDir', [ '$compile', function($compile) { return { restrict: 'E', link: function(scope, iElement, iAttrs){ // assigning things from iAttrs to scope goes here }, scope: '@', replace: false, templateUrl: 'myDir.html' }; }]); and then there is myDir.html, where I define a new element: <div class="example"

AngularJS : transcluding multiple sub elements in a single Angular directive

跟風遠走 提交于 2019-12-02 18:48:15
I am Fairly new to Angular but have been reading quite a lot. I was reading about ng-transclude at http://docs.angularjs.org/guide/directive#creating-custom-directives_demo_isolating-the-scope-of-a-directive and I think I understand properly what it does. If you have a directive that applies to an element that has content inside it such as in <my-directive>directive content</my-directive> It will allow you to tag an element within the directive's template with ng-transclude and the content included in the element would be rendered inside the tagged element. so if the template for myDirective

Is there a way to get the raw DOM element from an angular.element

ぐ巨炮叔叔 提交于 2019-12-02 18:41:32
angular.element All element references in Angular are always wrapped with jQuery or jqLite; they are never raw DOM references. How can I get the raw DOM element, because I have legacy JS code (jscolor Picker) that needs the raw DOM element? Found it: ang_element = angular.element(element); raw_element = ang_element[0]; 来源: https://stackoverflow.com/questions/18302493/is-there-a-way-to-get-the-raw-dom-element-from-an-angular-element

Child directive not updated when parent directive property changes

☆樱花仙子☆ 提交于 2019-12-02 18:34:55
问题 This is follow up to these 2 questions: Pass argument between parent and child directives Parent directive controller undefined when passing to child directive I have this part working; however, when the value for ng-disabled for parent directive changes, the child directive values don't get updated. Please see thin plunkr example. HTML: <div ng-app="myApp"> <div ng-controller="MyController"> {{menuStatus}} <tmp-menu ng-disabled="menuStatus"> <tmp-menu-link></tmp-menu-link> <tmp-menu-link><