We could revise this module such that the @NgModule decorator had a "providers" property like so:
providers:[SimpleDatePipe]
...and give the module a constructor like this:
constructor(pipe: SimpleDatePipe){
let whatever = new Date(1974,8,24);
let revamp = pipe.transform(whatever);
console.log(revamp);
}
This would work! If the pipe's transform method took more than one parameter at its signature, that too is easy to accomodate.
constructor(pipe: SimpleDatePipe){
let whatever = new Date(1974,8,24);
let revamp = pipe.transform(whatever,"hey");
console.log(revamp);
}
...and yet, you probably do not want to use pipes beyond the templates like this. This is gross.
No comments:
Post a Comment