angularjs-directive

What happened to the directives property in the Component decorator for Angular 2?

你离开我真会死。 提交于 2020-01-05 07:43:19
问题 I am using the Angular CLI v1.0.0-beta.19-3 to scaffold/build an Angular 2 website. I generate my component as follows ng g component file-upload . I noticed that the generated component file-upload.component.ts looks like the following. @Component({ selector: 'file-upload', templateUrl: './file-upload.component.html', styleUrls: ['./file-upload.component.css'] }) export class FileUploadComponent implements OnInit { ... } I need to use this component, ng2-file-upload, inside my own component.

With AngularJS, how can I conditionally add a class based on an action?

拥有回忆 提交于 2020-01-05 06:41:50
问题 My jQuery code looks like: $("body").on("click", ".nav-bar", function(e){ $(".my-nav").addClass("open"); }); I want to angular-ify this. There are a few different controller / views that will have a .nav-bar class, so I'm pretty sure I'll have to use a directive. I'm just not sure how to do that. Ideally, I can strip away all jQuery. Thanks 回答1: Create a directive: .directive("navbarAction", function() { return { restrict: 'A', //<---Look up what this does, there are other options link:

Create directive in typescript to show loading progress in angular

无人久伴 提交于 2020-01-05 05:31:12
问题 I am trying to create directive in Typescript which will keep watch on pending $resource requests. I want only one directive as an attribute which will be used with div in index.html to show loading progress. Below is my code for directive. module app.common.directives { interface IProgressbarScope extends ng.IScope { value: number; isLoading: any; showEl: any; } class Progressbar implements ng.IDirective { static $inject = ['$http']; static instance(): ng.IDirective { return new Progressbar;

AngularJS element onresize event - Custom Directive

血红的双手。 提交于 2020-01-05 05:28:06
问题 Does AngularJS have equivalent to this: elementObject.addEventListener("resize", myFunction); I thought about about watches, but I don't think it's the good solution. 回答1: Create a custom directive: app.directive("myResize", function($parse) { return { link: postLink }; function postLink(scope, elem, attrs) { elem.on("resize", function (e) { var rs = $parse(attrs.myResize); rs(scope, {$event: e}); scope.$apply(); }); } }); Usage: <div my-resize="$ctrl.myFunction($event)"> </div> For more

Modal not showing correctly when i put it into a Directive

允我心安 提交于 2020-01-05 04:44:23
问题 I can't reproduce the AngularStrap's example, here a working plunk What I get when I integrate this example in my code: (As you can see it's a bit darker, i don't know why...) What I'm expecting: Actually I spent a whole day looking for solution for this but no luck. guest.html <body ng-app="module.app"> <div class="container-fluid"> <nav class="navbar navbar-inverse navbar-static-top"> <div topbar></div> </nav> <div class="row"> <div ui-view></div> </div> </div> </body> topBar directive.js :

Issue with Isolated scopes in angular

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 04:05:14
问题 I am trying to run this program and I see no output. Can you please let me know what I am missing here. Thanks in advance. <html> <head ng-app="myApp"> <title>Test</title> <link rel="stylesheet" href="//cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script> </head> <body> <div my-directive my-url="http://www.google.com" my-click="Click me"> </div> </body> <script> angular.module('myApp',[])

angular custom validation unique email trigger once

ぐ巨炮叔叔 提交于 2020-01-05 03:35:18
问题 I'm having a lot of troubles and I don't understand the behavior of custom validation or may be I misunderstand something. The directive trigger once ousite watch and inside invalid and twice inside watch (at least in my test) My goal would be trigger the extra custom validation after the required and email rules are valid but it doesn't work at all. So the code <!doctype html> <html data-ng-app="myApp"> <head> <meta charset="utf-8"> </head> <body> <div data-ng-controller="myCtrl"> <form

How to pass a variable through scope into directive

我怕爱的太早我们不能终老 提交于 2020-01-05 03:00:15
问题 Inside an element directive named tabset , i am using element directive named tab twice which requires tabset . I am doing a console.log(attr.newvar) from link of tabset . newvar is the value passed into the scope of the tabset directive. So the tabset gets called 2 times (which i suppose is correct), and hence output is console d twice. 1st time, the console output is giving the correct output, but the 2nd time it is showing newvar as undefined . but i am not able to access newvar through

How to use relative path in Angular Google Maps directives?

徘徊边缘 提交于 2020-01-05 02:23:05
问题 I'm trying to set a custom marker on an AngularJS Google Map: <google-map draggable="true" style="display:block; width: 100%; height:100%;"> <markers> <marker ng-repeat="marker in markers" coords="marker" icon="../img/marker-map.png"> </marker> </markers> </google-map> This code throws the following error: Error: [$parse:syntax] Syntax Error: Token '.' not a primary expression at column 1 of the expression [../img/marker-map.png] starting at [../img/marker-map.png]. On the Angular Google Maps

Can not get element in directive while testing AngularJs + Jasmine

帅比萌擦擦* 提交于 2020-01-04 23:24:27
问题 I've got an angularjs directive with external template. It works well but I can not write jasmine unit tests for it. Here is plunker reproduced code: http://plnkr.co/edit/JPOBm7?p=preview All my tries failed on the same issue. Link method crashes on getting template's DOM element while running unit-test. It says: TypeError: canvas is null in http://run.plnkr.co/YHHxxmSgCiQxjrjw/app.js (line 8) I have no idea how to make it work. Help, please. My simplified directive code: angular.module('app'