This is very first post in the series of Angular 2 learning. In this post i am going to cover the basic concept of Angular 2. We will start with very basic fundamentals and will evolve Angular 2 slowly.
TYPE SCRIPT -
Angular 2 is written in Typescript, but it is not mandatory to use typescript if you want to build application in Angular 2. The biggest benefit of using Typescript is "Type".
As we know javascript is not type safe, hence refactoring/managing an application is pretty tedious. with Typescript we get type safety. There is typescript compiler(or transpiler) available which will convert your typescript into a javascript file.
So Typescript is only for compile time. Once your code is transpile, you get javascript as a output which is used by the application.
Please note every javascript is a typescript, hence Typescript is a superset of javascript. you can always copy your entire javascript code into typescript file and compile it.
Typescript also support "Interface" and we all know importance of interfaces in java/c#.
Components -
I am sure from various resource you must have seen that Angular 2 is component based framework. let's understand what does it mean.
Angular 2 components are evolved from the idea of webcomponent. The concept of webcomponent is to create resuable UI widgets. Using web-component you can visualize the app as a chunk of DOM elements, rather than a one single large page. The idea here is to compose the unit of functionality in a component, and reuse it across. This also means the CSS of this element will be limited to the component only.
In the webcomponent the HTML is hidden in form of Shadow DOM.
Shadow DOM -
Shadow DOM concept came while implementing web components. Shadow DOM is the part of the DOM, in hidden state.which means you are creating an HTML element, and innerHTML of that element is hidden( of course chrome gives you option by which you can see it). but as webcomponent talks about composition, the HTML and CSS are composed in the component and are understood by browser in form of shadow DOM.
With this architecture, all the css and functionality is very much encapsulated from the rest of the DOM. Ofcourse, javascript is not part of the shadow.
It is not actually directly part of the DOM, but its subtree which is connected with the DOM via rootNode. This also give an opportunity to browser to optimize the DOM manipulation. Because once there are changes in the Shadow DOM, browser need not to refresh the entire DOM.
Does it means the Angular component are drawn in shadow DOM? Nope. Web component and shadow DOM are new concepts and not all browser supports it, so Angular 2 gives us a chance to configure our app according to our need.
Component in Angular 2 -
For every component in Angular 2 you can define the state as -
None - All elements are draws normally, no shadow DOM concept.
Emulated - its in between of None and Native, Of course the DOM will be visible, but CSS will be scoped within the component and the root node will get some kind of proxy id associted. This is default.
Native - Shadow DOM is completly enabled.
Example - screenshot below compares these 3 scenarios -
How do we use API -
@Component({
selector: '..',
templateUrl: '..',
styleUrls: ['..'],
encapsulation: ViewEncapsulation.None
})
Components vs Directives -
Directive add behavior to the DOM element, whereas component creates its own view with its behavior.
Component is generally used to create UI widgets, it is a directive with a view..
Very nice write-up. I absolutely appreciate this website. Thanks!
ReplyDeleteAngularjs Training in Bangalore , Angular 2 Training in bangalore , Python Training in Bangalore
Thanks for sharing the article. It is very useful and informative. Are you searching for a best Angular training in kochi just visit Angular course in kochi
ReplyDeleteReally Great article. This article would be really helpful to the people who are working on AngularJS and dont know much about Services and Controllers. Thank you for sharing.Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles.
ReplyDeleteDevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
I need to to thank you for your time due to this fantastic read!! I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.keep up!!
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
it is very useful and informative. thanks a lot!!
ReplyDeleteangular js training in chennai
angular training in chennai
angular js online training in chennai
angular js training in bangalore
angular js training in hyderabad
angular js training in coimbatore
angular js training
angular js online training
Thanks for sharing your innovative ideas to our vision. I have read your blog and I gathered some new information through your blog. Your blog is really very informative and unique. Keep posting like this. Awaiting for your further update.
ReplyDeleteAWS Course in Chennai
AWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
it is very useful and informative. thanks a lot!!
ReplyDeleteacte chennai
acte complaints
acte reviews
acte trainer complaints
acte trainer reviews
acte velachery reviews complaints
acte tambaram reviews complaints
acte anna nagar reviews complaints
acte porur reviews complaints
acte omr reviews complaints
i was really impressed by seeing this article, it was very interesting and it is very useful for me.Thanks for sharing this wonderful content.its very useful to us.I gained many unknown information, the way you have clearly explained is really fantastic.
ReplyDeletepython training in bangalore
python training in hyderabad
python online training
python training
python flask training
python flask online training
python training in coimbatore
python training in chennai
python course in chennai
python online training in chennai
According to the Dice Salary Predictor, an iOS developer with five years of experience can earn an average of $83,500 to $112,500 in San Francisco; for an Android developer with the same experience in the same city, salaries are a little lower, ranging from $76,500 to $104,000.thanks !!
ReplyDeleteAndroid Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
Amazing wow!! I really appreciate your work. Thanks for the valuable information article.
ReplyDelete| Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course | CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course