Basic custom component


#1

Hi,

I’m looking to build a basic custom component that takes a number and prints ‘X’ instead. Like I have a simple function that converts a given number 2 to the corresponding string ‘XX’ and displays ‘XX’ on the web page.

import { Component } from ‘@angular/core’;

@Component({
selector: ‘cross’,
templateUrl: ‘{{numberToCross}}’ <- would return string
})
export class Cross {
constructor() {
}

numberToCross(value:number):string
// do the actual transformation … but how do I access the number value?
return result;
}

and using it <cross [value]=3> or whatever is best to access another input value

Any thoughts? I had a look at some web pages showing custom component creating but got lost rather quickly by the complexity.

Rgds
Lars