我正在从Angular 4.0.0升级到Angular 5.2.6
我正面临一些问题,让懒惰的模块加载工作.
使用角4.0.0,它工作正常,但现在,5.2.6,我点击我的重定向按钮时出现这样的错误:
core.js:1448 ERROR Error: Uncaught (in promise): TypeError: undefined is not a function
TypeError: undefined is not a function
at Array.map (<anonymous>)
at webpackAsyncContext (eval at ./src/$$_lazy_route_resource lazy recursive (main.bundle.js:27), <anonymous>:13:34)
at SystemJsNgModuleLoader.loadAndCompile (core.js:6558)
at SystemJsNgModuleLoader.load (core.js:6542)
at RouterConfigLoader.loadModuleFactory (router.js:4543)
at RouterConfigLoader.load (router.js:4523)
at MergeMapSubscriber.eval [as project] (router.js:2015)
at MergeMapSubscriber._tryNext (mergeMap.js:128)
at MergeMapSubscriber._next (mergeMap.js:118)
at MergeMapSubscriber.Subscriber.next (Subscriber.js:92)
at Array.map (<anonymous>)
at webpackAsyncContext (eval at ./src/$$_lazy_route_resource lazy recursive (main.bundle.js:27), <anonymous>:13:34) …Run Code Online (Sandbox Code Playgroud) javascript lazy-loading angular-routing angular angular-router
在我的剧本中,我需要为回购创建一个符号链接.
使用命令(shell)它可能像这样工作:
########## Create symbolic link
- name: Create symbolic link
shell : ln -s "{{SOURCE_FOLDER}}" SYMLINK
args :
chdir : "/opt/application/i99/"
when:
- ansible_host in groups['ihm']
Run Code Online (Sandbox Code Playgroud)
- > 像这样我的符号链接直接在i99 repo中创建/
SYMLINK - > SOURCE_FOLDER
但是在使用Ansible文件模块时,如下所示:
########## Create symbolic link
- name: Create symbolic link
file:
src: "/opt/application/i99/{{SOURCE_FOLDER}}/"
dest: "/opt/application/i99/SYMLINK"
state: link
when:
- ansible_host in groups['ihm']
Run Code Online (Sandbox Code Playgroud)
我的输出是这样的:
SYMLINK - > /opt/application/i99/SOURCE_FOLDER
因为我不希望它指向整个路径,我需要获得第一种格式:
SYMLINK - > SOURCE_FOLDER
我该怎么做?
我在我的ubuntu 14.04和节点8.0.0下使用NPM.
我已将我的npm从5.2.0升级到5.6.0
但之后所有的npm命令都失败了,表明存在以下问题:
节点-GYP/bin中/节点-GYP
完整的日志如下:
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'node-gyp/bin/node-gyp'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/khalidvm/.npm/_logs/2018-01-12T15_02_35_338Z-debug.log
khalidvm@ubuntu:~/Desktop$ gedit /home/khalidvm/.npm/_logs/2018-01-12T15_02_35_338Z-debug.log
^C
khalidvm@ubuntu:~/Desktop$ sudo npm uninstall npm -g
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'node-gyp/bin/node-gyp'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/khalidvm/.npm/_logs/2018-01-12T15_05_25_322Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我担心我无法使用npm,即使卸载它也会引发同样的错误.
我正在使用Angular 4,我正在运行: ng build --prod
我抓住了这个:
ng build --prod
Your global Angular CLI version (1.2.2) is greater than your local
version (1.0.0). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
Hash: 7fce5d10c4c3ac9745e8
Time: 68351ms
chunk {0} polyfills.7790a64cc25c48ae62ea.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk {1} main.f10680210e9e45ed33cc.bundle.js (main) 382 kB {3} [initial] [rendered]
chunk {2} styles.d2e6408caea42ccabf99.bundle.css (styles) 175 bytes {4} [initial] [rendered]
chunk {3} vendor.fc69ec31f7ef40b5fffb.bundle.js (vendor) 5.9 MB [initial] [rendered]
chunk {4} inline.91747411075ce6c7f438.bundle.js …Run Code Online (Sandbox Code Playgroud) javascript production-environment typescript webpack angular
在我的角度应用程序中,我正在使用这种处理方法
myMethod(){
...
setTimeout(() => {
this.router.navigate(['mucomponent']);
});
}
Run Code Online (Sandbox Code Playgroud)
正如我被告知的:setTimeout 没有延迟(0)似乎等待下一个蜱虫完成所有治疗后开始我的治疗。这是近期的计划。
因为我需要这种行为
是否有任何干净的替代方法可以用typescript或rxjs做同样的事情来做得更好?
建议?
我正在使用我的角度4.0.0应用程序进行单元测试,我的实际组件中的一些方法是通过以下方式调用手动路由:
method(){
....
this.navigateTo('/home/advisor');
....
}
Run Code Online (Sandbox Code Playgroud)
使用navigateTo是一个自定义路由方法,调用此方法:
public navigateTo(url: string) {
this.oldUrl = this.router.url;
this.router.navigate([url], { skipLocationChange: true });
}
Run Code Online (Sandbox Code Playgroud)
我有这个路由文件:
import ... // Components and dependencies
const homeRoutes: Routes = [
{
path: 'home', component: HomeComponent,
children: [
{
path: 'registration',
component: RegistrationComponent,
children: [
{
path: 'synthese',
component: SyntheseComponent
},
{
path: 'queue',
component: QueueComponent,
children: [
{
path: 'queue-modal',
component: QueueModalComponent
},
{
path: 'confirm',
component: ConfirmComponent
}
]
}
]
},
{
path: 'toolbox', …Run Code Online (Sandbox Code Playgroud) 我mat-autocomplete在我的 Angular 应用程序下使用小部件:
<mat-form-field class="col-md-3" color="warn">
<input type="text"
id="libelleShop"
#inputSelectShop
placeholder="Selectionner la boutique"
matInput
formControlName="libelleShop"
ngDefaultControl
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete""
(optionSelected)="onShopSelectionChanged($event)">
<mat-option *ngFor="let shop of shopData" [value]="shop.value">
{{shop.name}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我的商店数据是这样的:
shopData = [
{name: 'AAA' , value :'11'},
{name: 'BBB', value :'22'},
{name: 'CCC', value : '33'}
];
Run Code Online (Sandbox Code Playgroud)
这样的-选项被显示name,但在选择由输入displaysitvalue不是name。
知道我需要其他治疗的价值,我不会改变[value]的mat-automplete。
我如何将名称引用到输入中?
建议??
angular-material angular-material2 angular angular-material-6
我有一个 ansible 角色,如下所示:
\n\nmy-role\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 files\n\xe2\x94\x82 my-file-one\n\xe2\x94\x82 my-file-two\n\xe2\x94\x82 my-file-...\n\xe2\x94\x82 my-file-n\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80 tasks\n main.yml\nRun Code Online (Sandbox Code Playgroud)\n\n在我的main.yml中,我有这个递归复制任务,\n并且我想复制所有文件,而不需要手动列出它们:
\n\n- name: copy all files\n copy:\n src: "{{ item }}"\n dest: /dest/\n with_items:\n - ????\nRun Code Online (Sandbox Code Playgroud)\n\n建议??
\n我的应用程序属于Angular 5.2.6
事情是正常的 ng serve
但是在运行时:ng build --prod在失败之前需要一段时间
这些错误似乎与clean-css操作有关:
错误跟踪:
92% chunk asset optimization/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/input-source-map-tracker.js:37
if (originalPosition.line === null && line > 1 && selectorFallbacks > 0) {
^
TypeError: Cannot read property 'line' of undefined
at originalPositionFor (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/input-source-map-tracker.js:37:23)
at originalMetadata (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/tokenizer/tokenize.js:486:43)
at intoTokens (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/tokenizer/tokenize.js:240:75)
at tokenize (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/tokenizer/tokenize.js:74:10)
at fromStyles (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/read-sources.js:147:12)
at fromString (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/read-sources.js:48:10)
at doReadSources (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/read-sources.js:33:12)
at readSources (/home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/reader/read-sources.js:24:10)
at /home/khalidvm/Desktop/Workspace/Front/frontend_v2/node_modules/clean-css/lib/clean.js:99:12
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
Run Code Online (Sandbox Code Playgroud)
它似乎在清洁CSS时失败了.
这是我的package.json:
{
"name": "test",
"version": …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,我想 在同一时刻 使用 相同的路由路径延迟加载两个模块。
我的路由模块如下所示:
{
path: 'mypath',
loadChildren: () => HomeModule,
canLoad: [HomeGuard]
},
{
path: 'mypath',
loadChildren: () => AdvisorModule,
canLoad: [AdvisorGuard]
},
Run Code Online (Sandbox Code Playgroud)
但这导致只加载第一个
我无论如何都找不到这样做,例如:
{
path: 'mypath',
loadChildren: () => HomeModule, advisor module // ??
canLoad: [// ??]
},
Run Code Online (Sandbox Code Playgroud)
我也不想在另一个中导入其中一个,像这样,只有一个模块会被延迟加载,另一个会自动加载
怎么可能呢??
javascript lazy-loading typescript angular-ui-router angular
angular ×7
javascript ×6
typescript ×5
ansible ×2
ansible-2.x ×2
lazy-loading ×2
angular-cli ×1
clean-css ×1
ecmascript-6 ×1
jasmine ×1
node-gyp ×1
node.js ×1
npm ×1
npm-install ×1
rxjs ×1
ubuntu-14.04 ×1
webpack ×1