Angular2 create custom Pipes with import problems
With angular2 RC.1 we created a custom Pipe and import some classes we need to create the pipe. Only now we migrate to final angular release and we are not able to import any of the classes we need.
import { isBlank, isString, isArray, StringWrapper, CONST } from 'angular2/src/facade/lang';
import { BaseException } from 'angular2/src/facade/exceptions';
import { ListWrapper } from 'angular2/src/facade/collection';
import { InvalidPipeArgumentException } from 'angular2/src/common/pipes/invalid_pipe_argument_exception';
Can someone tell us where we can found this classes, we are not able to find them, also not in the code. So what is happening with all them?
These were all refactored out of the public API purposefully around the RC6 timeframe, if I remember right. If you go through the source code on github you'll see that in most cases these exist but are no longer exported anywhere. There is a github issue going back to April of 2015 which highlights the thinking behind removing these internal utilities from public exposure:
Facades are here to abstract JS / Dart differences. We don't want to be in business of providing general helper functions as there are already plenty of libraries that do just that in a generic manner. Facades are minimal and for internal use - we don't want to grow those to sth generic as not to add too many bytes to the framework.
https://github.com/angular/angular/issues/3886
You'll either need to find libraries that implement what you need or build your own out.
isString, for example is a straightforward typeof
: Check if a variable is a string
isBlank can be accomplished by checking if it's a string and then seeing if the thing is blank with a regex.
Exceptions would be derived from error: How do I extend a host object (eg Error) in TypeScript where you throw the new error.
You asked what happened to them, and I answered.
链接地址: http://www.djcxy.com/p/94986.html下一篇: Angular2创建导入问题的自定义管道