Тёмный
No video :(

Angular 2 nested components 

kudvenkat
Подписаться 832 тыс.
Просмотров 293 тыс.
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
In this video we will discuss nesting angular components i.e including a component inside another component.
Angular 2 is all about components. A component in Angular allows us to create a reusable UI widget. A component can be used by any other component. Let's look at a simple example of nesting a component inside another component.
Create a page that displays Employee details. This page should be composed of 2 angular components
AppComponent - This component is the root component and displays just the page header.
EmployeeComponent - This component is the child component and displays the Employee details table. This child component will be nested inside the root AppComponent.
Step 1 : Right click on the "App" folder and add a new folder. Name it "employee". We will create our EmployeeComponent in this folder.
Step 2 : Right click on the "employee" folder and add a new HTML page. Name it employee.component.html. Copy and paste the following HTML.
[table]
[tr]
[td]First Name[/td]
[td]{{firstName}}[/td]
[/tr]
[tr]
[td]Last Name[/td]
[td]{{lastName}}[/td]
[/tr]
[tr]
[td]Gender[/td]
[td]{{gender}}[/td]
[/tr]
[tr]
[td]Age[/td]
[td]{{age}}[/td]
[/tr]
[/table]
Step 3 : Right click on the "employee" folder and add a new TypeScript file. Name it employee.component.ts. Copy and paste the following code in it. At this point we have our child component EmployeeComponent created. Next let's create the root component - AppComponent.
import { Component } from '@angular/core';
@Component({
selector: 'my-employee',
templateUrl: 'app/employee/employee.component.html'
})
export class EmployeeComponent {
firstName: string = 'Tom';
lastName: string = 'Hopkins';
gender: string = 'Male';
age: number = 20;
}
Step 4 : We are going to use the root component to just display the page header. So in "app.component.ts" file, include the following code. Notice, since the View Template HTML is just 3 lines we have used an inline template instead of an external template. Angular2 recommends to extract templates into a separate file, if the view template is longer than 3 lines.
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `[div]
[h1]{{pageHeader}}[/h1]
[/div]`
})
export class AppComponent {
pageHeader: string = 'Employee Details';
}
At this point if we run the application, we only see the page header - "Employee Details", but not the table which has the employee details. To be able to display employee details table along with the page header, we will have to nest EmployeeComponent inside AppComponent. There are 2 simple steps to achieve this.
Please refer to the text article using the link below for the code used in the demo
csharp-video-tu...

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

 

27 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 114   
@Archak77
@Archak77 7 лет назад
Pls include Part # in the video title
@cfv717
@cfv717 4 года назад
Explanation is clear and easy to understand. Thanks
@iBoolGuy
@iBoolGuy 4 года назад
Hello Mr Venkat, I followed this playlist from beginning, and installed all necessary files. I'm on VS2019. But, at 2:30, when I right click on a folder, and click Add, I don't have the option to add TypeScript File. Although I checked the installed version in my VS program, and it says (TypeScript Tools for Microsoft Visual Studio 16.0.10821.2002) (I installed the latest version from MS website, and through NuGet manager... help
@Iamdolphin1987
@Iamdolphin1987 6 лет назад
Great video, and awesome teacher. Highly recommend
@venkatramana331
@venkatramana331 3 года назад
no one comes close to you in explaining difficult topics sir.
@houssamfertaq8428
@houssamfertaq8428 6 лет назад
My best teacher !
@its_rohitp
@its_rohitp 4 года назад
Great video, Thank you so much.
@nageshsrinivas8045
@nageshsrinivas8045 6 лет назад
thank you very much for the tutorials sir..it has helped me a lot.
@shariqansari4056
@shariqansari4056 6 лет назад
@kudvenkat , I am a big fan of your tutorials. From last 7 years learning from your videos. Waiting React.js videos from yourside.
@muhammadkamranmalik9614
@muhammadkamranmalik9614 3 года назад
Great tutorial! Thank you.
@uyk-qn7yq
@uyk-qn7yq 7 лет назад
Very good explanation, thank you!
@ethanz4928
@ethanz4928 6 лет назад
I do not know why the style not appear in my browser, no matter how i changed the color or manually refresh the browser, no any effects at all. All other contents are same as yours, just the style has problem. The only link should be in index.html to link my styles.css right? So do u know what's the problem may cause this issue? Thanks.
@VivekBaghel1806
@VivekBaghel1806 6 лет назад
did you found the solution??.I am also getting same problem
@ParthTanna8
@ParthTanna8 4 года назад
@@VivekBaghel1806 did you find the solution? I am facing the same issue
@gtrj55tgjr
@gtrj55tgjr 6 лет назад
Typescript option is not available on my visual studio , i have installed typescript even on install command prompt but typescript is not visible while click on "add", html and javascript is avaible but typescript is not
@rabeihzeineddine
@rabeihzeineddine 4 года назад
I have these errors when I reload the project: Severity Code Description Project File Line Suppression State Error Build:Property 'lift' in type 'Subject' is not assignable to the same property in base type 'Observable'. WebApplication1 F:\My Web Sites\Angular\AngularDemo2\WebApplication1 ode_modules xjs\Subject.d.ts 24 Severity Code Description Project File Line Suppression State Error Build:Property 'lift' in type 'Subject' is not assignable to the same property in base type 'Observable'. WebApplication1 F:\My Web Sites\Angular\AngularDemo2\WebApplication1 ode_modules xjs\Subject.d.ts 24 Error TS2416 (TS) Property 'lift' in type 'Subject' is not assignable to the same property in base type 'Observable'. Type '(operator: Operator) => Observable' is not assignable to type '(operator: Operator) => Observable'. Type 'Observable' is not assignable to type 'Observable'. Type 'T' is not assignable to type 'R'. 'T' is assignable to the constraint of type 'R', but 'R' could be instantiated with a different subtype of constraint '{}'. F:\My Web Sites\Angular\AngularDemo2\WebApplication1\src (tsconfig or jsconfig project) F:\My Web Sites\Angular\AngularDemo2\WebApplication1 ode_modules xjs\Subject.d.ts 24 Active
@fareedalam2353
@fareedalam2353 7 лет назад
thanks Sir Great Technique to Teach
@shraddhapaliwal4817
@shraddhapaliwal4817 5 лет назад
Hello Sir , Please upload videos on MEAN.js . nobody except you can make my concepts clear. I love each and every tutorial of u.Thanks.
@oscaronorato
@oscaronorato 6 лет назад
Hi Kudvenkat, I can see employee data, but I can see the table except in Firefox. because it can be? This refers to the .css and I do not understand the reason. Tank you.
@oscaronorato
@oscaronorato 6 лет назад
The answer will be found in the next video by using styleUrls who refers to a .css file.
@stanleyakachukwu5386
@stanleyakachukwu5386 7 лет назад
Good one! Go on bro!
@CaimanNet
@CaimanNet 7 лет назад
Thanks a lot Sir. We were waiting for this Angular 2 series. Please try to cover how to make an Application using AngularJS2, Typescript , NGRX & WebAPI.
@kiranshelke1627
@kiranshelke1627 7 лет назад
Hello Sir.. video says if a class contains "@comopnent" then it become "Angular Component" but if class contains "@NgModule" then also it becomes "Angular Component" ??.. make me correct...! Thanks
@Csharp-video-tutorialsBlogspot
Hello Kiran, If a class is decorated with "@comopnent" decorator then it becomes an "Angular Component" and if a class is decorated with "@NgModule" then it becomes an "Angular Module" NOT "Angular Component". In the video I misspoke. Very sorry about the confusion that created. Hope this clarifies.
@kiranshelke1627
@kiranshelke1627 7 лет назад
Thank you sir...!! its cleared now. appreciate your efforts..!!
@mhsindia8970
@mhsindia8970 7 лет назад
if a class contain "@NgModule" it is angular module,we can define our code into different modules like" admin module,login module...."
@DjProGamerMan
@DjProGamerMan 7 лет назад
you can add CC so that others may not get confused
@tipukhan3529
@tipukhan3529 6 лет назад
no issues sir, its really great video
@mhsindia8970
@mhsindia8970 7 лет назад
hi sir , is there any way to import js file into typescript
@dayanandchauhan683
@dayanandchauhan683 4 года назад
Facing error my-employee is not a eliment in console part.. I wrote evryting according to your teaching.. So how can resolve it . Sir. I got it but practice time facing error..
@abhishekvhanmore176
@abhishekvhanmore176 6 лет назад
sir if we have html file which we link as templateurl in under app folder then the selector for that html page where we should use that selector for displaying or bootstraping our app?? help me sir it showing can't find module
@jeremiedupont8696
@jeremiedupont8696 2 года назад
Thank you!
@sachindhawan9114
@sachindhawan9114 7 лет назад
Nice Tutorials.
@ajaysriram2351
@ajaysriram2351 7 лет назад
Hi Venkat, I need a calendar it display only years. Along with calendar icon. Now I am using in drop-down. So I need like that. Can you guide me... Thanks, Ajay
@gayatrirudrabhatla5347
@gayatrirudrabhatla5347 4 года назад
Got the error TS2416 as build error. Please help me out
@rabeihzeineddine
@rabeihzeineddine 4 года назад
I have the same error
@harshitashukla8975
@harshitashukla8975 6 лет назад
Hi, if I add a new folder(employee) with a ts,html and css file, it gives me an error "module not found". It was not happening until today. I have been working on this for 2 days, now it gives me this error. Could you please help. Thanks
@deepakjakhmola8763
@deepakjakhmola8763 6 лет назад
In VS 2015 there is no option displaying to add Typescript. Please help how I can add Typescript in VS2015.
@choudharyrahul722
@choudharyrahul722 6 лет назад
Sir, styles are not getting applied to the nested component!! is coming without style...
@zarrarpalekar9622
@zarrarpalekar9622 5 лет назад
facing same, any fix?
@zarrarpalekar9622
@zarrarpalekar9622 5 лет назад
Issue resolved, just clear cache and cookies of the browser you are using, or else open in some other browser.
@ragahavavani3663
@ragahavavani3663 4 года назад
HostResourceResolver: could not resolve app/Employee/Employee.Component.html and templateurl is not coming automatically pls tell me solution sir....
@andrewharvley-felder4502
@andrewharvley-felder4502 7 лет назад
Great video thank you. If you have a nested component or components, how, when you refresh the page, do you bring the user back to the same state they were in pre refresh?
@choudharyrahul722
@choudharyrahul722 6 лет назад
Sir Please show how to use Angular 2 in Visual Studio 2017. How should I configure VS 2017? Getting so many errors every time I am building the solution in VC 2017.
@prashantbiradar7896
@prashantbiradar7896 6 лет назад
Fabulous! Thank you.
@mahendrakumarsahoo129
@mahendrakumarsahoo129 6 лет назад
Hello Sir, I'm a follower of urs and just try to code the above things. But after coding, my browser still displaying "Hello Angular" but not "Employee Details" . Clean the solution and rebuilt but no luck , same contains. Tried to google but didn't find any solution. Please help me why after changes in the code, Angular2 not showing updated contains. Thanks Mahendra
@Csharp-video-tutorialsBlogspot
I think the most likely cause is, the browser has cached the previous version of the file. Please try the following and let us know if it has helped. 1. Reload the web page by pressing CTRL + F5 or CTRL + R 2. Delete browser history and try again
@ajayParmar-ee5if
@ajayParmar-ee5if 6 лет назад
have you check folder/file path properly ?
@user-bi4tw3gb5p
@user-bi4tw3gb5p 6 лет назад
CTRL+SHIFT+R works.
@mangalashirodkar5172
@mangalashirodkar5172 4 года назад
Root component bootstraps our application... What is the meaning of this ?
@sandeepelr
@sandeepelr 6 лет назад
hi sir i got an error to compile this nested component sir it shows ./src/app/employee/employee.component.ts module not found: error: can't resolve. please help me sir how to get this
@aneeshchandran06
@aneeshchandran06 7 лет назад
pls provide a SSIS, SSAS, SSRS Tutorial
@banditalks
@banditalks 7 лет назад
hi venkat iam getting maximum call stack size exceeded error can u please tell how can we resolve this
@aariefe33
@aariefe33 7 лет назад
Excellent videos to learn angular 2. I have watched part 1-6. When r further parts coming?
@mahmoudaldajani8290
@mahmoudaldajani8290 5 лет назад
To show the employee table border on chrome and IE as well, use pt instead of px. td { border: 1pt solid black;}
@sanjaychouhan2061
@sanjaychouhan2061 6 лет назад
Hello sir thanks for your effort.i have a question is it possible to add multiple component inside bootstrap array in app.module.ts. if Yes then what is use case thanks
@chetanpl
@chetanpl 7 лет назад
dear sir please make a video for event handing. suppose I have 2 components and it is used in 1 page and there both components has buttons. now I want click at 1st component button and its changes the background color of second component. if I do the same with second component button than it will change the background color of first component button. sir please explain the code . how can we do it I request you sir.
@12345678958200
@12345678958200 5 лет назад
Failed to load resource: the server responded with a status of 404 (Not Found) zone.js:682 Unhandled Promise rejection: Template parse errors: Parser Error: Unexpected token 'Name' at column 7 in [{{first Name}}] in ng:///app/Employee/Employee.component.html@9:16 ("
@sunilkunapareddy2215
@sunilkunapareddy2215 6 лет назад
Hai boss... Your explanation is so clear and I came to nested very well... And I have a doubt... Cant i include both tempeleturl and tempelet in same component? As I know both can't be at one place i saw that in angular website ... But I wanna write one html file speeately and other html should be in my component tempelet... Plz reply me... I have this doubt... And both html created link and html code should be in one template ... Plz reply me bhayya
@benjaminlim3799
@benjaminlim3799 6 лет назад
only templateUrl or template will load, depending on which one comes last.
@Travelbyblacksky
@Travelbyblacksky 4 года назад
How we push object inside array please upload a video sir
@chandanjena5214
@chandanjena5214 5 лет назад
Module not found: Error: Can't resolve './employee/employee.component.html'..Could you please suggest why this error is coming?
@jassimashraf1008
@jassimashraf1008 5 лет назад
this error is because your employee folder is outside app folder. It should be inside app folder.
@byteburn-vlog
@byteburn-vlog 5 лет назад
./src/app/employee/employee.component.ts Module not found: Error: Can't resolve './/app/employee/employee.component.html' in '/Users/ryadav/Documents/Angular7/ng7/src/app/employee'
@manikantajupudi4129
@manikantajupudi4129 3 года назад
Thanks, Sir.
@rashedhossen6635
@rashedhossen6635 6 лет назад
I am getting this error. [ERROR ->]"): ng:///app/employee/employee.component.ts@14:1 Invalid ICU message. Missing '}'. (" gender: string = 'male'; age: number = 20; can't find any solution.
@lP-fq3yl
@lP-fq3yl 7 лет назад
I have got a problem, my styles were not adding to the output
@eswararya196
@eswararya196 7 лет назад
i also got the same problem
@eswararya196
@eswararya196 7 лет назад
my styles are not resoponding
@udyamadamanchi7141
@udyamadamanchi7141 6 лет назад
it's working Rajon Tanducar, thank you man
@VivekBaghel1806
@VivekBaghel1806 6 лет назад
thanx buddy
@ParthTanna8
@ParthTanna8 4 года назад
my styles are not working can someone please help
@RachitJain4U
@RachitJain4U 5 лет назад
Awesome :) Thanks :)
@chandanraj2741
@chandanraj2741 7 лет назад
It's showing an error employee.component.ts is not a module.
@shayanhafeez5405
@shayanhafeez5405 6 лет назад
Hello sir Please make video series on Node js as well
@gopala.n5442
@gopala.n5442 7 лет назад
venkat sir, pls make a vedio on angular 2 http, as I have tried calling Mvc controller through http, but am getting error "405" method not allowed. pls help. Thanks
@itsforall7959
@itsforall7959 6 лет назад
how the css file refered in emploee.componet.html page?
@krishnag645
@krishnag645 6 лет назад
Hi venkat can you please provide unit cases related tutorials in angular 2 I searched for your video I didnt find
@hrvojekrolo3166
@hrvojekrolo3166 6 лет назад
Hi! Great videos! Can you make video about form registration and login with ASP MVC and Angular 2?
@josephregallis3394
@josephregallis3394 6 лет назад
Employee table border does not show up in Chrome. Works fine in IE.
@sandeepchegu6849
@sandeepchegu6849 6 лет назад
localhost:4200/src/runtime.js 404 not found error showing after nesting the compinent and executing can any one please tellme how to solve this
@sidken4
@sidken4 7 лет назад
I want to run that employee.component.html page separately. i am not able to do that.. please help.
@amrutpardeshi7339
@amrutpardeshi7339 7 лет назад
You can't because you are calling that employee.component.html from app.component.ts (from the template)
@sidken4
@sidken4 7 лет назад
if i want to run that page(and other pages) separately what should i have to do. like we do it in asp.net webforms
@johnny_rain3226
@johnny_rain3226 7 лет назад
for (Int64 i = 0; i < Int64.MaxValue Console.WriteLine("Thank You!");
@RonyMattar
@RonyMattar 7 лет назад
Thank you! :)
@ShivamShukla-nn6uf
@ShivamShukla-nn6uf 7 лет назад
I cannot create a new folder in app. There is no option for creating the new folder. Please help.
@srinivasrapaka4729
@srinivasrapaka4729 7 лет назад
I think You are code is run mode that time not allow to create folder
@ShivamShukla-nn6uf
@ShivamShukla-nn6uf 7 лет назад
ok this problem this solved. Thanks
@ambitionworldit4168
@ambitionworldit4168 6 лет назад
Geting this below error: How to fix it. Severity Code Description Project File Line Suppression State Error TS2416 Property 'lift' in type 'Subject' is not assignable to the same property in base type 'Observable'. Type '(operator: Operator) => Observable' is not assignable to type '(operator: Operator) => Observable'. Type 'Observable' is not assignable to type 'Observable'. Type 'T' is not assignable to type 'R'. TypeScript Virtual Projects D:\Practies Examples\Angular Practical\Angular2\Angular2Demo\Angular2Demo ode_modules xjs\Subject.d.ts 24 Active Severity Code Description Project File Line Suppression State Error Build:Property 'lift' in type 'Subject' is not assignable to the same property in base type 'Observable'. Angular2Demo D:\Practies Examples\Angular Practical\Angular2\Angular2Demo\Angular2Demo ode_modules xjs\Subject.d.ts 24
@hamzehhanandeh3647
@hamzehhanandeh3647 7 лет назад
thank you
@mahmoudaldajani8290
@mahmoudaldajani8290 5 лет назад
To show border on chrome just use pt instead of px , td { border: 1pt solid black;}
@nageswar88
@nageswar88 7 лет назад
Thank you sir
@raqibul1000
@raqibul1000 7 лет назад
Thanks a Trillions.
@RachitJain4U
@RachitJain4U 7 лет назад
Thank You Sir :)
@Circularmotion07
@Circularmotion07 7 лет назад
When is the next video coming out?
@badrulhussain5545
@badrulhussain5545 7 лет назад
I am getting build error on subject.d.ts, app.component.spec.st, app.module.ts, stconfig.json has anyone came across these files to have errors ?
@joselingstonmoses6458
@joselingstonmoses6458 7 лет назад
great ...
@Dellenite
@Dellenite 6 лет назад
Compedent?
@sumersinghrana8868
@sumersinghrana8868 7 лет назад
angular 2 has master page concept or not?
@nagireddypinnelli6590
@nagireddypinnelli6590 7 лет назад
not yet introduce
@mhsindia8970
@mhsindia8970 7 лет назад
in angular 2 we only single page that is index.html in app.. component.ts it is shown,
@lP-fq3yl
@lP-fq3yl 7 лет назад
can any one please let me know reason and how to solve it
@sashidhar2285
@sashidhar2285 4 года назад
Use Visual Studio Code and it is much easier.
@rehbarsheikh1063
@rehbarsheikh1063 7 лет назад
thank u sir
@enhancejavahub7692
@enhancejavahub7692 3 года назад
Timestamp 9:43 you wanted to say module but you said..... class decorated with ngModule class becomes a component 🤪 -------------------------------------------------- I know your mean was a module not component
@adekunleoyaniyi3221
@adekunleoyaniyi3221 7 лет назад
The style is not applying to the table and td
@Csharp-video-tutorialsBlogspot
After applying the slides, please reload the web page by pressing CTRL + F5 keys simultaneously. Hope this helps.
@adekunleoyaniyi3221
@adekunleoyaniyi3221 7 лет назад
Thanks, work like a magic
@MrMintu1
@MrMintu1 7 лет назад
awesome :)..nice trick sir.. hats off to you
@sofiagoyal1759
@sofiagoyal1759 7 лет назад
hii...i am still unable to add style...as far as i can see on console the style is not saved though in visual studio it is saved
@raqibul1000
@raqibul1000 7 лет назад
Pls include Part # in the video title
Далее
Styling angular 2 components
11:18
Просмотров 197 тыс.
Property binding in Angular 2
10:36
Просмотров 203 тыс.
ЛОВИМ НОВЫХ МОНСТРОВ В LETHAL COMPANY
2:42:22
C’est qui le plus fort 😂
00:18
Просмотров 9 млн
Avaz Oxun - 10 yillik yubiley konsert dasturi 2023
2:52:33
Liskov: The Liskov Substitution Principle
4:23
Просмотров 21 тыс.
Angular 2 container and nested components
11:09
Просмотров 137 тыс.
Why dependency injection
11:53
Просмотров 156 тыс.
AngularJS - Services
8:16
Просмотров 12 тыс.
Angular services tutorial
13:52
Просмотров 170 тыс.
ЛОВИМ НОВЫХ МОНСТРОВ В LETHAL COMPANY
2:42:22