03. Architecture overview - Metadata



Architecture overview - Metadata

Angular වලදී භාවිතා වනMetadata,Typescript class decorate කරන්න භාවිතා කරන අතර මෙම Metadata හරහා class එකක behaviour එක කොහොමද කියලා configure කරන්න පුළුවන්.

TypeScript class – without metadata

export class Department implements OnInit {
}

TypeScript class – with metadata 

@Component({
selector: 'app-department-detail',
template: ‘app/department.component.hrml
styles: []
})

export class Department implements OnInit {

}


මෙහිදී @Component මගින් Department class  එක components ක් බව angular වෙත කියන අතර ''selector","templateUrl" වැනි decorators හරහා  class එකේ behaviour  එක configure කර ඇත.නමුත් මෙම Metadata එක භාවිතා කරන තුරු එය component එකක් බව  angular නොදනී.( @Component is a decorator that gives the Deparment class more functionality using the metadata (selector, templateURL) associated with it).

decorator is a function that has a configuration object.

Typescript class has metadata attach to it. It contain information that angular needs to decide whether particular class infects to angular module or it is just a regular class. Meta data is defining using decorator which is a feature in typescript. It is just a function that provides information about the class which attach to it. Within the Component, we use component decorator.

Comments

Popular posts from this blog

02. Spring – Creating spring project clone it with GIT step by step.

02.What is MicroService?

06.Mongo DB - Query part 2 (Aggregation)