Тёмный
No video :(

Angular component output properties 

kudvenkat
Подписаться 832 тыс.
Просмотров 154 тыс.
50% 1

Text version of the video
csharp-video-tu...
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our RU-vid channel. Hope you can help.
/ @aarvikitchen5572
Slides
csharp-video-tu...
Angular 2 Tutorial playlist
• Angular 2 tutorial for...
Angular 2 Text articles and slides
csharp-video-tu...
All Dot Net and SQL Server Tutorials in English
www.youtube.co...
All Dot Net and SQL Server Tutorials in Arabic
/ kudvenkatarabic
Search Tags
angular 2 component output example
angular 2 component output event
angular 2 component output properties
angular child component output
angular2 child component call parent function
angular2 eventemitter between components
angular2 eventemitter callback
angular2 eventemitter child
angular2 eventemitter emit
angular2 eventemitter import
eventemitter in angular2
angular2 eventemitter not working
angular2 eventemitter sample
angular2 eventemitter tutorial
angular2 eventemitter typescript
In this video we will discuss
1. How to pass user actions or user entered values or selections from the child component to the parent component using output properties.
2. We will discuss creating custom events using angular EventEmitter class
3. What is ng-container directive and it's use
At the moment when we click the radio buttons, nothing happens. Here is what we want to do.
All(6) radio button is clicked - Display all the employees in the table
Male(4) radio button is clicked - Display the 4 Male employees in the table
Female(2) radio button is clicked - Display the 2 Female employees in the table
To achieve this we are going to make use of component output properties. First let's look at the changes required in the nested component i.e EmployeeCountComponent.
The changes required in employeeCount.component.ts are comented and self-explanatory
// Import Output and EventEmitter
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'employee-count',
templateUrl: 'app/employee/employeeCount.component.html',
styleUrls: ['app/employee/employeeCount.component.css']
})
export class EmployeeCountComponent {
@Input()
all: number;
@Input()
male: number;
@Input()
female: number;
// Holds the selected value of the radio button
selectedRadioButtonValue: string = 'All';
// The Output decorator makes the property an Output property
// EventEmitter class is used to create the custom event
// When the radio button selection changes, the selected
// radio button value which is a string gets passed to the
// event handler method. Hence, the event payload is string.
@Output()
countRadioButtonSelectionChanged: EventEmitter[string] = new EventEmitter[string]();
// This method raises the custom event. We will bind this
// method to the change event of all the 3 radio buttons
onRadioButtonSelectionChange() {
this.countRadioButtonSelectionChanged.emit(this.selectedRadioButtonValue);
}
}
The following are the changes required in the view template of EmployeeCountComponent i.e employeeCount.component.html. Notice we have made 3 changes on each radio button
1. value attribute is set to (All, Male or Female)
2. Implemented 2 way data-binding using the ngModel directive. Notice ngModel is bound to selectedRadioButtonValue property in the component class. This 2 way data-binding ensures whenever the radio button selection changes, the selectedRadioButtonValue property is updated with the value of the selected radio button.
3. onRadioButtonSelectionChange() method is binded to "change" event of the radio button. So this means whenever, the selection of the radio button changes, onRadioButtonSelectionChange() method raises the custom event "countRadioButtonSelectionChanged". We defined this custom event using Angular EventEmitter class.
[span class="radioClass"]Show : [/span]
[input name='options' type='radio' value="All" [(ngModel)]="selectedRadioButtonValue" (change)="onRadioButtonSelectionChange()"]
[span class="radioClass"]{{'All(' + all + ')'}}[/span]
[input name="options" type="radio" value="Male" [(ngModel)]="selectedRadioButtonValue" (change)="onRadioButtonSelectionChange()"]
[span class="radioClass"]{{"Male(" + male + ")"}}[/span]
[input name="options" type="radio" value="Female" [(ngModel)]="selectedRadioButtonValue" (change)="onRadioButtonSelectionChange()"]
[span class="radioClass"]{{"Female(" + female + ")"}}[/span]

Опубликовано:

 

27 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 101   
@TrungNguyen-vt1nc
@TrungNguyen-vt1nc 5 лет назад
Supper hero, Kudvenkat! your series saved my life!
@furqans.mahmoud4511
@furqans.mahmoud4511 6 лет назад
.you know exactly what an angular beginner need to learn Thanks alot
@vishaljaiswal3202
@vishaljaiswal3202 7 лет назад
Sir please make a video CRUD with angular 2
@PraveenKumar-ft2kr
@PraveenKumar-ft2kr 4 года назад
Awesome as always. Thank you so much sir:)
@deepwoodsengineering3763
@deepwoodsengineering3763 5 лет назад
You're a legend, buddy!
@nareshe9906
@nareshe9906 4 года назад
Query1) say if the selection of the radio button is in same component then by giving onclick method ,if that on click method has some flag value and by using the flag value to its achievable? please confirm? Query2) But here the selection is belongs to some other component so here we are trying to pass data from one component to other component by using event emitter is it correct.?
@danishbaharia8927
@danishbaharia8927 2 года назад
Thank you for the nice explanation
@mansijoshi4923
@mansijoshi4923 3 года назад
understandable ! topic !! easy to understand ..
@arpanbanerjee8584
@arpanbanerjee8584 5 лет назад
very clear cut explanation! thank you!
@parashuramhosmani1581
@parashuramhosmani1581 4 года назад
Nice explanation 👍👍👍
@saishree1000
@saishree1000 4 года назад
Super sir, clearly explained. Thanks for your efforts. Keep it up more videos
@sasanknvs5603
@sasanknvs5603 7 лет назад
I have a query. What would the two way binding of 'SelectedRadioButtonValue' do ? Is it going to set the value property ? If so, it is already hardcoded with 'All,male and female'. how is it going to make difference ? or is it going to select the radio button ? In this case what property of control, the 'SelectedRadioButtonValue' will be bound to ?
@DecentProgrammer
@DecentProgrammer 3 года назад
nice video
@djus5
@djus5 5 лет назад
Very good lessons!
@subrahmanyam80
@subrahmanyam80 6 лет назад
Very nice explanation... Great effort in creating such a nice video series. Thank you so much ......
@yamunaa5367
@yamunaa5367 4 года назад
Hi sir, I'm trying to this example with mat-table. But I'm unable to filter data, since we cannot have multiple * conditions in mat-row. Please help me out sir. Thanks in advance
@priyankkeshri1619
@priyankkeshri1619 5 лет назад
this make more sense for filtering: OnEmpRbChange(selectedRbEmpValue: string): void { this.selectedRbEmpValueCS = selectedRbEmpValue; if (selectedRbEmpValue != 'All') { this.employees = this.Allemployees.filter(e => e.gender === selectedRbEmpValue); } else { this.employees = this.Allemployees; } } rather than using *ngIf
@mariappan7kumar
@mariappan7kumar 6 лет назад
@kudvenkat Seriously this is how Angular 2 does radio button filter? Angular js needs just 6 lines of HTML code. How can we call this as an improvement from version 1?
@gunnarweisskamp1530
@gunnarweisskamp1530 6 лет назад
Completely agree. I find many things in Angular complete rubbish.
@24306529
@24306529 6 лет назад
I was about to say same thing.. this is way too complicated .. and this is just a radio button..I don't know what will happen if you start building some complex applications..it seems the responsibility of defining events and ngModels is on developers in Angular2..angularJS gives lot of things for free!
@cristianscript5649
@cristianscript5649 5 лет назад
but it is scalable and efficient for some reason angular 1 was depreceated
@hamzehhanandeh3647
@hamzehhanandeh3647 6 лет назад
Thank you for your effort, great videos
@47lokeshkumar74
@47lokeshkumar74 3 года назад
How your male is showing as 4. female 2, All is 6,. How your are counting kindly help me plz
@willkwan6783
@willkwan6783 5 лет назад
I'm getting a very weird behavior, I tried to duplicate this component (eg. employeeList and employeeList2), so I created two folders, however in my "employeeList2" folder, I removed the "employeeCount.component" files, and referenced to use the original employeeCount component (since I didn't want to "repeat codes") in my HTML. Then I put in the app.component.html page the following markup: All looks fine so far, except when you click the radio button of the bottom component, it also clicks the radio button of the top. Even more weird is that the radio buttons in the bottom component doesn't show the black dot (ie. it doesn't show any radio button being selected). Is this the wrong way to reuse components? Can't you have 2 components that uses the same employeeCount component? Or is it because the employeeCount emits and raises an event? Please can someone help.
@chiragratra3741
@chiragratra3741 6 лет назад
If suppose the number of males or females are 0 , it is till going to display the how can we handle that or just show no record found ?? as we cannot simply handle it by this code of line *ngIf="!employees || employees.length==0". Please Sir if you could just provide a little more input
@JoshPius
@JoshPius 4 года назад
Thank you so much!
@theprogrammer1677
@theprogrammer1677 7 лет назад
hi, I would appreciate an answer - I write this because normally you don't answer the comments. First of all, thank you for the best angular tutorials I have ever seen! Secondly, my question is if you are going to do more of the tutorials or if this was the last one? And if yes, when are you going to upload them?
@raqibul1000
@raqibul1000 7 лет назад
Thanks a Billions.
@Hariharan0606
@Hariharan0606 7 лет назад
Hello Sir!! A crystal clear explanation indeed.I have a question . we can still achieve the same without using @Input or @output . In which scenario(apart from passing data between components) , custom event binding and property binding will be required?
@cristianscript5649
@cristianscript5649 5 лет назад
it was hard to grasp but finally I understood
@manchusandy1
@manchusandy1 6 лет назад
Hello Sir. Why the method onRadioButtionSelectionChange() is not having a return type? why it is not causing error? (At 4:30)
@karthikb4298
@karthikb4298 5 лет назад
It would be very helpful if you add one more input element search box filter to this use case. Thank you.
@dayanandchauhan683
@dayanandchauhan683 5 лет назад
Great explains sir..
@nessd1
@nessd1 6 лет назад
Output decorator can only be used on events. However the documentation says "bindingPropertyName" and don't clarify this.
@ShyamKumar9396
@ShyamKumar9396 5 лет назад
Hi @kudvenkat, is it possible to get date format to input type range from component
@manikantajupudi4129
@manikantajupudi4129 3 года назад
Thanks, Sir.
@AsifHameedeteksol
@AsifHameedeteksol 7 лет назад
I tried all videos one by one but getting this error on current video: ERROR TypeError: co.onRadiobuttonSelectionChange is not a function at Object.eval [as handleEvent] (employeeCount.component.html:6) at handleEvent (view.ts:141) at callWithDebugContext (services.ts:645) at Object.debugHandleEvent [as handleEvent] (services.ts:241) at dispatchEvent (util.ts:173) at eval (element.ts:222) at HTMLInputElement.eval (dom_renderer.ts:75) at ZoneDelegate.invokeTask (zone.js:424) at Object.onInvokeTask (ng_zone.ts:253) at ZoneDelegate.invokeTask (zone.js:423) can sone one guide me where i am wrong.
@nessd1
@nessd1 6 лет назад
There can be useful naming convention on input and output properties
@niharikamiryalavk
@niharikamiryalavk 4 года назад
Awesome guruji :)
@rajarajanseeman6758
@rajarajanseeman6758 6 лет назад
Awesome lesson
@RECKED_NOXIN
@RECKED_NOXIN 7 лет назад
Nice video i have seen on angular 2
@tazmazia5726
@tazmazia5726 6 лет назад
Can be place all the *ng directive on ng-container ?
@shinojmm
@shinojmm 4 года назад
Sir, Output event name in parent is diff from the declaration of out event in child?
@royarazi5043
@royarazi5043 4 года назад
VERY GOOD!!!
@sonuuniyal502
@sonuuniyal502 5 лет назад
can't we use custom filter for that?
@mohammedyousef4344
@mohammedyousef4344 6 лет назад
but you can use filter as prev video
@harikagunti8001
@harikagunti8001 4 года назад
Hi, I have two components, I want to send socket connection from the first component to another component, am using Ionic and angular2+ for mobile app, so please help me
@gurjotsingh752
@gurjotsingh752 6 лет назад
Hi Sir, which component render first ? container( employeeList) component or nested component(employeeCount) ? Flow is bit confusing. can u please put a debugger and let us know the flow. thanks
@PraveenKumar-ft2kr
@PraveenKumar-ft2kr 4 года назад
Just add console.log statements to both the constructors. :)
@chandrasekharmanepali1493
@chandrasekharmanepali1493 6 лет назад
Hi sir, from above concept if male or female employees not available in list of employees, are we get still colspan row with "No employees to dispaly" ?
@karthikb4298
@karthikb4298 5 лет назад
If you dont have male or female then there is no point in using this eg. or you can simply add anohter radio calling others and filter the list.
@velen3358
@velen3358 7 лет назад
So similar to Event in C#.
@aparnalonkar1764
@aparnalonkar1764 6 лет назад
Hi Sir, I write the same code but value is not changing after selecting male , I am still able to see all the values(it should display male only). No errors are there . when I select male/female/all, I am able to see the changes in console but its not changing in UI. Plz help
@katerahul2011
@katerahul2011 5 лет назад
I am having the same issue. The properties and event are not getting bound. Did you find the issue?
@aruppanda6049
@aruppanda6049 7 лет назад
is this the last video of angular2?
@mohmmadalnaddaf4495
@mohmmadalnaddaf4495 7 лет назад
perfect thank you. so much
@amanjutt1591
@amanjutt1591 7 лет назад
Mohammad Alnddaf plz explain what is the difference between Angular and AngularJS???
@rajusivananda
@rajusivananda 4 года назад
how to pass data between 2 component if they are not connected? any video on that class will be helpful.
@MuhammadAbdullah-cn4qz
@MuhammadAbdullah-cn4qz 6 лет назад
[(ngModel)] doesn't work when i run application with f5 in visual studio. But When i run application using npm start in cmd then [(ngModel )] is Working. Please Tell me what to do. I don't know what's going on
@gnakzor
@gnakzor 6 лет назад
You're probably using a cached version of the webpage. If you're using Chrome, open developer tools (F12), go to Network tab and make sure Disable cache checkbox is checked. Then refresh your webpage using SHIFT+F5 to clear the cached version. If it doesn't work try to close all browser windows and then run the app from Visual Studio. Other browsers have the same option, I just don't know exactly where it's located so search a bit. Hope this helps.
@lokeshpanwar1618
@lokeshpanwar1618 6 лет назад
hello sir, while I select All then it hit 'Female' and randomly it through radio button values where I miss will you help me. I did code same as yours.
@deepkarmakar3510
@deepkarmakar3510 6 лет назад
I'm also facing the same issue.
@sohailshaik9045
@sohailshaik9045 6 лет назад
Hi my ngmodel is binding after Click event so it returning an old value anyone can help?
@varun123456789rty
@varun123456789rty 7 лет назад
I WONDER HOW THE CODE IS WORKING !! Name of our custom event was ''countRadioButtonSelectionChanged" in our child component but 12:22 method of the parent class is binded to onEmployeeCountRadioButtonChange i.e (onEmployeeCountRadioButtonChange)="onEmployeeCountRadioButtonChange($event)'". AM I GOING WRONG SOMEWHERE ?
@velen3358
@velen3358 7 лет назад
jump to 16:00, it's just a mistake
@Arvind8311
@Arvind8311 6 лет назад
you are correct an video is wrong!!
@mohittri8066
@mohittri8066 6 лет назад
Hello sir i am facing an issue. Can't bind to 'ngModel' since it isn't a known property of 'input'.
@AAA12345671234567
@AAA12345671234567 6 лет назад
import form from angular core
@mohittri8066
@mohittri8066 6 лет назад
himanshu tripathi I use the exactly code which is written in the blog of this lecture.
@puttaarunkumar919
@puttaarunkumar919 6 лет назад
Hello mohit the issue over their is formsModule must be imported in app.module.ts and must be added in the @NgModule decorator.
@preetikumari7214
@preetikumari7214 5 лет назад
import { FormsModule } from '@angular/forms'; @NgModule({ imports: [ FormsModule ], add in app.module.ts
@gopalnichal8888
@gopalnichal8888 7 лет назад
@Kudvenkat Sir pls upload a video on Http services
@hrvojekrolo3166
@hrvojekrolo3166 6 лет назад
When I run this example on Chrome it's doesn't work. It works correctly on Firefox and Opera? Anyone have the same problem?
@shanilshah5283
@shanilshah5283 6 лет назад
I have same, did you found any solution?
@ajitpedha6381
@ajitpedha6381 5 лет назад
@@shanilshah5283 Try doing hard reset on chrome and reload,it should work
@priyatiwari7791
@priyatiwari7791 5 лет назад
chapters":[{"id":"5ace205", "subject":[{"id":"5ace20","name":"Biology"}]} How i will display name of the subject? {{chapters.subject[name]}}
@rahulsalunkhe8364
@rahulsalunkhe8364 5 лет назад
As I go further i m getting more and more confuse in this video. Request you to make another video. Please help..
@piupaul2454
@piupaul2454 6 лет назад
Hi Sir, first of all thank you for these great videos. But for this module, when I am selecting any radio button, getting the previous value of the selected one. Please Help. Thanks again :)
@PraveenKumar-ft2kr
@PraveenKumar-ft2kr 4 года назад
You should have used (click) event instead of (change) event. i just now corrected :D after so much research. lol
@47lokeshkumar74
@47lokeshkumar74 3 года назад
try to code into github bro
@amanjutt1591
@amanjutt1591 7 лет назад
Sir Plz tell me what is the difference between Angular and AngularJS???
@divyangdesai1634
@divyangdesai1634 7 лет назад
Angular JS is a JavaScript framework, wheres Angular (2 and so on) is just completely revived framework. You can find more at: dzone.com/articles/typed-front-end-with-angular-2
@amanjutt1591
@amanjutt1591 7 лет назад
Sir Divyang Desai this article that you mention is about angular 2 and angular 1 not about angularjs and angular
@divyangdesai1634
@divyangdesai1634 7 лет назад
LOL, Have you checked wiki? en.wikipedia.org/wiki/AngularJS Which stated "AngularJS (commonly referred to as "Angular.js" or "AngularJS 1.X")" Hope that make sense!
@amanjutt1591
@amanjutt1591 7 лет назад
sir thank soo much for helping me
@abdelhafidsaou6815
@abdelhafidsaou6815 6 лет назад
Not an easy things to understand ! I needed to replay this video many times to understand what is going there with that advanced concept in angular !
@betaakurnia3998
@betaakurnia3998 5 лет назад
you are not alone man :D
@yasser2768
@yasser2768 5 лет назад
because the way he explains it is crap
@srushtidaware7978
@srushtidaware7978 4 года назад
it took one hour for me to understand the video, replayed it many times!
@VinayBhardwaj1
@VinayBhardwaj1 6 лет назад
This translation on screen hide 20-30 percent of code part pls do the needful to get rid of this
@Csharp-video-tutorialsBlogspot
Hello Vinay, please turn off the closed captions using the settings button on the player. You will find the settings button on the bottom right hand corner of the player. Hope this helps.
@VinayBhardwaj1
@VinayBhardwaj1 6 лет назад
kudvenkat thanks this worked for me
@loveChroniclesTv
@loveChroniclesTv 4 года назад
this is hardest the hardest part. too many pieces moving around.
@emergingtechinfo4980
@emergingtechinfo4980 7 лет назад
I have one doubt.. AngularJS going down fall in front react.js does it help us in future learning this AngularJS. Please can you explain me detailed.. Thanks in advance..
@divyangdesai1634
@divyangdesai1634 7 лет назад
Nope, Angular Js and Angular(2,4 & 5) are two different things, if we consider angular and react yes both are good for future learning. You can check trends onStack Overflow: imgr.es/3PIV And more information from here: www.c-sharpcorner.com/article/angular-2-or-react-for-decision-makers/
@emergingtechinfo4980
@emergingtechinfo4980 7 лет назад
@divyang thank you for reply and info with links. I have seen latest trends showing as react on top position except in india that is why im asking this question. im posting the latest trends link below please have a look. goo.gl/2iKKrC
@divyangdesai1634
@divyangdesai1634 7 лет назад
Hey, this is bit interesting now, actually both have positive and negative points that what I tried to show you using that c-sharpcorner link. And use of different technologies by region is very obvious. Moreover, your query has terms "angularjs, angularjs 2,react" which are irrelevant with comparison. I've modified your query and now you can see the actual thing: trends.google.com/trends/explore?q=angular,reactjs
@emergingtechinfo4980
@emergingtechinfo4980 7 лет назад
:) Thank you, Desai for helping me to find out the comparison. but I feel React.js is getting popular than Angular.js. because I am getting calls on react more than Angularjs here in india too.. If my guess is not correct I will be happy because I learnt Angular.js and waiting for job.
@divyangdesai1634
@divyangdesai1634 7 лет назад
Hey, still I would like to say "Angular.js" and "Angular" are two different things. And people are using more react because it is stable and easy to learn as compare to angular. If you ask about future, interfering DOM element is future as per current trend.
@jvppriyanka7467
@jvppriyanka7467 4 года назад
NJ