Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pipe): added the Pipe decorator and the pipe property to View
BREAKING CHANGE: Instead of configuring pipes via a Pipes object, now you can configure them by providing the pipes property to the View decorator. @pipe({ name: 'double' }) class DoublePipe { transform(value, args) { return value * 2; } } @view({ template: '{{ 10 | double}}' pipes: [DoublePipe] }) class CustomComponent {} Closes #3572
- Loading branch information
Showing
62 changed files
with
623 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 39 additions & 1 deletion
40
modules/angular2/src/change_detection/change_detection_util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {ABSTRACT, BaseException, CONST, Type} from 'angular2/src/facade/lang'; | ||
|
||
/** | ||
* An interface which all pipes must implement. | ||
* | ||
* #Example | ||
* | ||
* ``` | ||
* class DoublePipe implements PipeTransform { | ||
* onDestroy() {} | ||
* | ||
* transform(value, args = []) { | ||
* return `${value}${value}`; | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
export interface PipeTransform { | ||
onDestroy(): void; | ||
|
||
transform(value: any, args: List<any>): any; | ||
} | ||
|
||
/** | ||
* Provides default implementation of the `onDestroy` method. | ||
* | ||
* #Example | ||
* | ||
* ``` | ||
* class DoublePipe extends BasePipe { | ||
* transform(value) { | ||
* return `${value}${value}`; | ||
* } | ||
* } | ||
* ``` | ||
*/ | ||
@CONST() | ||
export class BasePipeTransform implements PipeTransform { | ||
onDestroy(): void {} | ||
transform(value: any, args: List<any>): any { return _abstract(); } | ||
} | ||
|
||
function _abstract() { | ||
throw new BaseException('This method is abstract'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {PipeTransform} from './pipe_transform'; | ||
|
||
export interface Pipes { get(name: string): PipeTransform; } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.