Angular JS මුලසිට – 2

Share with your friends!

කලින් article එකේ නවත්තපු තැනින් පටන් ගමු එහෙනම්. දැන් වැඩේ පටන් ගන්න ඕන කරන දේවල් ටික හරි. මේ tute එකට editor එක විදයට sublime text editor එකයි, browser එක විදියට Opera Browser එකයි තමයි use කරන්නේ.

1

මුලින්ම folder එකේ index.html එක create කරගන්න ඕන. download කරපු files දෙකත් add කරගන්න. Angular වලදී Modules Structure එකක් තමයි use කරන්නේ. code එකේ components හඳුන්වන්නේ module විදියට. මේක නිසා code එක maintainable, readable වෙනවා.

Create First Module

app.js කියලා අලුත් file එකක් හදලා මේ code එක add කරන්න.

[code language=”javascript”]
var app = angular.module(‘store’, [ ]);
[/code]

Include module

දැන් මේ file එක index.html එකට add කරගන්න ඕන.

2

දැන් Angular module එකට දෙන්න ඕන store කියන module එක active වෙන්නේ මොන scope එකෙදීද කියන එක. ඒ කියන්නේ මොන tag එක ඇතුලෙද වැඩ කරන්නේ කියන එක. දැනට HTML tag එකට add කරමු. Large app එකකදී වෙන වෙනම scope වලට modules run වෙනවා.

3

Module එකකින් මොනවද කරන්න පුළුවන්?

Angular වල තියන feature එකක් තමයි Angular Expressions කියන්නේ. මේකෙන් පුළුවන් HTML document එකට dynamic values add කරන්න.

4

උඩින් තියන div element එක process උනාම ලැබෙන්නේ යටින් තියන div element එක. මේ ගැන වැඩිදුර විස්තර මෙතනින් බලන්න පුළුවන්.

දැන් බලමු code එකට add කරගන්නේ කොහොමද කියලා.

5

Output එක මේ විදියට බලන්න පුළුවන්.

6

Complex data එක්ක වැඩ කරන්නේ කොහොමද කියලා next article එකේ බලමු.

 

Share with your friends!

5 comments

  1. Binura Dodangoda

    As I see the biggest difference between AngularJS and Angular 2 is modules. AngularJS doesn’t have modules. Whole AngularJS library is a module. But in Angular 2 it is broken down into set of modules and we can use the modules which we only want. And each module is composed of set of components.

Leave A Comment

shares