Creating Reusable Directives in AngularJS

  Рет қаралды 54,261

Joe Maddalone

Joe Maddalone

Күн бұрын

Пікірлер: 61
@AWESOMEJX271
@AWESOMEJX271 9 жыл бұрын
This is the second time one of your framework videos has helped me. Thanks for putting this together! I like how the example is lean enough to type into an editor, then tweak it until you understand how it works.
@edko8286
@edko8286 10 жыл бұрын
this is the best angularjs directive tutorial so far.
@mujib517
@mujib517 9 жыл бұрын
Hi Joe, Awesome Video. Just an FYI. There are three types of scopes in angular directives. 1. Shared Scope 2. Inherited Scope 3. Isolated Scope. Ex: scope:false (shared scope and its default) scope:true (inherited scope. parent scope is visible) scope:{} (isolated scope parent scope is not visible).
@Andrea-Giachetto
@Andrea-Giachetto 9 жыл бұрын
Hi Joe, with this video you helped me out to understand the "module" concept and I'm very grateful to you
@everdimension
@everdimension 10 жыл бұрын
The difference between assinging scope to be "true" and "{}" is that in the first case the directive's scope becomes an instance of the parent scope (the scope of the parent controller) and therefore can use its data. But when we write 'scope: {}', we get a fully isolated scope without direct access to the parent scope.
@heymauriciosoares
@heymauriciosoares 11 жыл бұрын
Thank you so much! until now i didnt know what directives was, or where to use... now i'm full of ideas for my project! Sir, you rock!
@bengienickSerrano
@bengienickSerrano 9 жыл бұрын
Excellent video, very clear and precise.
@SAlmanKhanDev
@SAlmanKhanDev 8 жыл бұрын
Very straightforward! This is the perfect way to teach intermediate developers.
@Tefrax
@Tefrax 11 жыл бұрын
Thanks Joe, I've read/watched quite a few directive tutorials, yours really helped me on the link function. Thanks!
@TarekFaham
@TarekFaham 8 жыл бұрын
Wow! Very simple and very useful. Now I fully understand how to develop reusable form parts in Angularjs. Thank you so much.
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Thanks Mauricio. I am almost jealous of you... that first time that Angular starts to makes sense is really exciting.
@akhilnegi100
@akhilnegi100 10 жыл бұрын
best AngularJS tutorial out here.Thanks Joe Maddalone...
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Good questions, Miguel! First, yes, I am injecting the module into APP, and the module could contain multiple directives and more (services, factories, etc.) As far as having a module for every directive, I would consider the complexity and potential for reuse in other projects before creating a new module. In my example I took something trivial and created a module to teach the concept and and show the method, but the example directive would not have warranted it in production.
@nonefvnfvnjnjnjevjenjvonej3384
@nonefvnfvnjnjnjevjenjvonej3384 4 жыл бұрын
These videos got me my start in pro web dev.
@MarcosMaiaGroo
@MarcosMaiaGroo 10 жыл бұрын
That's a great simple introduction that shows many aspects of Directives. Thanks.
@mustaphag
@mustaphag 9 жыл бұрын
Nice video, This is the first time i am able to write my own directive because of your video
@prithvisinh
@prithvisinh 10 жыл бұрын
This video is really awesome. The explanation is crystal clear. Thank you Joe for presenting such a nice tutorial.
@dhafirnz
@dhafirnz 11 жыл бұрын
Thanks heaps. I was looking for the "re-usability" part of the directive. Very well explained.
@ShikharDadhich
@ShikharDadhich 9 жыл бұрын
Simply awesome, thanks for defining in such a simple way. You covered almost all important I was looking for. Thanks again!!!
@yashmittal198
@yashmittal198 3 жыл бұрын
Yo, just commenting since there is no comment from past 4 years. Great video thanks
@MrZeeshantufail
@MrZeeshantufail 9 жыл бұрын
There is a difference when we set scope:true or scope:{} when set to true , it means that directive template can inherit scope from the parent directives or controllers. but not the siblings. when set to {}, it means that no outer scope is available in the directive template.
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Better separation is certainly a good goal, but there are a number of ways to achieve this without requiring jQuery. You could use the templateUrl option in the directive linking to an external HTML file, or a an inline template script with a type of "text/ng-template."
@zackmacomber
@zackmacomber 10 жыл бұрын
Very helpful. I find so many things posted are unhelpful and leave me frustrated and this does just the opposite. Please keep posting your thoughts/discoveries.
@brycepj1
@brycepj1 10 жыл бұрын
Great stuff, Joe! Thanks for putting it together!
@salasiapro
@salasiapro 11 жыл бұрын
Very Instructive. Just what I was looking for. Thanks for this.
@SKDurgesh
@SKDurgesh 10 жыл бұрын
hey @Joe Maddalone, that plugins and all you installing by command prompt is there any othere way i mean downloading from website and put that in directory and work from there.. please guide me, I am rookie in angular
@gunishraichawla
@gunishraichawla 11 жыл бұрын
Sorry a bit off-topic, but how did you setup sublime to get to create a HTML 5 blank template ? Do you have other handy tips like these ? perhaps make a video, also about bower and other bits would be useful ?
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Try these: AngularJS Filters plus some Sublime & Bower tips Introduction to Bower
@gunishraichawla
@gunishraichawla 11 жыл бұрын
Joe Maddalone Perfect! Thanks!
@DanHaywood
@DanHaywood 11 жыл бұрын
Good explanation of writing a directive...to the point.
@عيسىمحمدعلي-ج6خ
@عيسىمحمدعلي-ج6خ 11 жыл бұрын
Thank you for this good tutorial, I think for a good separation fo html and javascript code , we have to create the template inside html in a script tag and use it with jQuery .html() method in the template attribute of angular.js. Do you agree with me ?
@gabrielagabi5480
@gabrielagabi5480 10 жыл бұрын
Hey Joe :) At the end of the video you are putting the directive into a module and you are inserting the js file into the index.html page. So I was wondering, if my application gets really big and I have let's say 10 different modules each having different directive(s), do I have to include every js with the directives manually in the index.html file? Do you know if there is another way to gather all this directives in one place and include all js files just once into index.html ? Thank you, Gabriela
@RemcoPeggeman
@RemcoPeggeman 10 жыл бұрын
Yes you can, there are multiple ways to do this. I always use templates and views, so I only place them in the index.html and do some routing (search for routing in angular for more info). You could also create an HTML file with all your scripts and do a ng-include. Ofcourse you would have to import angular itself. Otherwise it won't work.
@gunishraichawla
@gunishraichawla 11 жыл бұрын
Just discovered something that sounded a bit odd, the Link and Template don't work together now in context of this example. What is happening is that the template is rendered before the attributes are picked up from the link function. Another video tells me that transclude does the trick ? But i could not figure out how to pickup attributes in a template by setting transclude:true ? Any Tips ?
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Had to recreate it from my own video, but still works just fine. plnkr.co/edit/Ar92D0etGj7f8QoajM3X I also have a video on transclude here: AngularJS Transclude
@gunishraichawla
@gunishraichawla 11 жыл бұрын
Joe Maddalone The difference is, it no longer works with custom element directives. I forked your example and changed the directive .. have a look. plnkr.co/edit/FuUJRTCXqC0EAbWs2KWC?p=preview
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
You want to change namer="" to just namer. This is the difference between using the [A]ttribute vs the [E]lement version of the directive.
@tobiasmucksch9441
@tobiasmucksch9441 11 жыл бұрын
Very useful - and very concise. Thank you!
@drescore
@drescore 11 жыл бұрын
scope: true - this creates a new scope for the directive that prototypically inherits from the parent scope (so that you have access to parent scope data). Downside (or not) is that if you have several directives on an element (e.g. as attributes), there's only one scope created for them (inherited from the element's scope) scope: {} - it creates a new, "isolated" scope. it means it does not inherit from parent scope, so you don't worry about parent vars - useful for reusable components :)
@dlodeprojuicer
@dlodeprojuicer 11 жыл бұрын
This really helped alot! This tutorial is on point. Thank you!
9 жыл бұрын
Very good. Simple and direct.
@aboel3zz
@aboel3zz 10 жыл бұрын
Very Very helpful, I know how to write my own directive now, thank you so much
@mindlesssingularity
@mindlesssingularity 11 жыл бұрын
That's a great tutorial, Thanks, Could you share how to use combined restrict option in a directive, like restrict : 'ECA', ?
@SoftDevPhilosophy
@SoftDevPhilosophy 10 жыл бұрын
Very helpful! Thanks very much for this tutorial!
@89ankit89
@89ankit89 9 жыл бұрын
simple and superbb video...keep up the spirit :) you got +1 subscriber..
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
Luckily, no parent scopes were harmed in the making of this example, but thanks for the pointer, Michael.
@warn2571
@warn2571 9 жыл бұрын
@11:40 you said {} works and true works also and you didn't know why {} works. I believe the reason why it works is because it is looking for a truthy statement and in JavaScript and empty object literal is a truthy value. ({} == true) is true or you can just test it with !!{} It is one of the weird things about JS.
@MrZeeshantufail
@MrZeeshantufail 9 жыл бұрын
+Michael Warner no brother there is a big difference in using {} or true. There is a difference when we set scope:true or scope:{} when set to true , it means that directive template can inherit scope from the parent directives or controllers. but not the siblings. when set to {}, it means that no outer scope is available in the directive template.
@numicago
@numicago 10 жыл бұрын
This was awesome!!
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
I get the loud keyboard thing a lot... I think I have situated things better in later videos to avoid it being so loud. Who knows... maybe it's my trademark now.
@gnanaselvan2010
@gnanaselvan2010 9 жыл бұрын
@Joe Maddalone "That's really cool explanation"
@YonathanBenitah
@YonathanBenitah 9 жыл бұрын
very clear! Thank you
@toothpickfactory4720
@toothpickfactory4720 10 жыл бұрын
Awesome vid. Thank you =)
@SampathLokuge
@SampathLokuge 9 жыл бұрын
Awesome.Thanks a lot :)
@xAockd
@xAockd 11 жыл бұрын
Thx for video! Please recording more video about angularjs
@stofstik
@stofstik 9 жыл бұрын
Awesome :)
@venki1429
@venki1429 11 жыл бұрын
awesome..
@meitalv8091
@meitalv8091 11 жыл бұрын
great !
@JoeMaddalone
@JoeMaddalone 11 жыл бұрын
@MunzirSuliman
@MunzirSuliman 11 жыл бұрын
i luv u mowah , no homo :)
AngularJS $watch and object equality
12:51
Joe Maddalone
Рет қаралды 13 М.
Dave Smith  - Deep Dive into Custom Directives - NG-Conf 2014
33:50
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
How To Make Angular Code More Reusable
19:14
Decoded Frontend
Рет қаралды 31 М.
Google I/O 2013 - Design Decisions in AngularJS
40:00
Google for Developers
Рет қаралды 208 М.
John Papa - 10 AngularJS Patterns - Code on the Beach 2014
1:01:27
Code on the Beach
Рет қаралды 83 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
End to End with Angular JS
52:59
David Mosher
Рет қаралды 130 М.
Introduction to Angular JS
50:05
David Mosher
Рет қаралды 200 М.
The Right Way To Build Async APIs in ASP.NET Core
20:12
Milan Jovanović
Рет қаралды 22 М.
Introduction to Angular.js in 50 Examples (part 2)
54:43
Curran Kelleher
Рет қаралды 188 М.
AngularJS Directives Tutorial - Part 1 - Demystifying Angular Directives
18:59
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН