这是一个标准的angular.json文件
"projects": {
"myApp": {
[...]
"architect": {
"build": {
[...]
"configurations": {
"production": { [...] },
"debug": { [...] }
}
},
"serve": {
[...]
"configurations": {
"production": {
"browserTarget": "myApp:build:production"
},
"debug": {
"browserTarget": "myApp:build:debug"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道该browserTarget设置什么?我找不到任何文档,看来我不得不深入研究@angular-devkit...
这是我的ui-router工作得很好:
ngModule.config(['$stateProvider',
function ($stateProvider) {
$stateProvider
.state('homepage', {
url: '',
templateUrl: '/partials/homepage/'
})
.state('item', {
url: '/item/:item_id',
templateUrl: function ($stateParams) {
return '/partials/item/' + $stateParams.item_id + '/';
}
})
.state('search', {
url: '/search/?q',
templateUrl: function ($stateParams) {
return '/partials/search/?q=' + $stateParams.q;
}
});
}]);
Run Code Online (Sandbox Code Playgroud)
路由工作正常.唯一的问题发生在搜索状态.在这种情况下,浏览器的返回按钮不起作用.唯一不同的是2之前来自字符串查询.如何修复后退按钮以使其处理字符串查询?
我想知道之间的区别是什么:
@mixin transition($args...) {
-webkit-transition: $args;
-moz-transition: $args;
-ms-transition: $args;
-o-transition: $args;
transition: $args;
}
Run Code Online (Sandbox Code Playgroud)
和
@mixin transition($args...) {
-webkit-transition: #{$args};
-moz-transition: #{$args};
-ms-transition: #{$args};
-o-transition: #{$args};
transition: #{$args};
}
Run Code Online (Sandbox Code Playgroud)
在争论面前有#的目的是什么?
我有以下代码:
<my-comp [title]="Foo's component"></my-comp>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多东西('',\',\\',\'',...)逃避',但是我没能做到这一点。我怎样才能做到这一点 ?
我一直在标签中使用svg或作为背景图像.最近关注:https://css-tricks.com/using-svg/ 我想直接注入我的svg.Angular4有任何功能允许吗?
我刚刚浏览了那边的文档https://angular.io/guide/testing
component = fixture.debugElement.componentInstance
component = fixture.componentInstance
Run Code Online (Sandbox Code Playgroud)
但我还没有理解这两者之间的区别
在 Angular4 中,您可以使用loadChildren路由配置中的属性延迟加载模块pathToMyModule#MyModule。我想知道是否可以指定任何属性来始终加载我的模块(因此基本上禁用延迟加载)。
我有一个启动 InAppBrowser 的移动应用程序:
const browser = window.open(url, '_blank', 'location=no,clearsessioncache=yes,clearcache=yes,usewkwebview=yes');
browser.addEventListener('loadstart', async (e) => {
...
});
Run Code Online (Sandbox Code Playgroud)
在我的网站上导航时,如果我单击特定的button,我想向我的移动应用程序发送一条消息,以便它可以执行操作。无论如何我可以这样做吗?一种巧妙的方法是更改,window.location.href以便它确实触发loadstart一些查询参数,但它至少强制重新加载我的页面。
编辑:
这似乎是一个线索
if (window['webkit'] && window['webkit'].messageHandlers && window['webkit'].messageHandlers['cordova_iab']
&& window['webkit'].messageHandlers['cordova_iab'].postMessage) {
window['webkit'].messageHandlers['cordova_iab'].postMessage(JSON.stringify({'data': 'value'}))
}
Run Code Online (Sandbox Code Playgroud) 在 Angular9 中,我试图做一个:
this.router.navigate(['my-route']);
Run Code Online (Sandbox Code Playgroud)
它定义在我的 app-routing.module.ts
{
path: 'my-route',
loadChildren: () => import('./custom/custom.module').then(m => m.CustomModule),
outlet: 'custom'
},
Run Code Online (Sandbox Code Playgroud)
和
CustomModule
Run Code Online (Sandbox Code Playgroud)
有以下路线:
{
path: '',
component: CustomComponent
}
Run Code Online (Sandbox Code Playgroud)
当我触发navigate我得到:
Uncaught Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
- JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
- Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?
- Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
Run Code Online (Sandbox Code Playgroud)
我实际上设法通过添加到我的 main.ts
import '@angular/compiler';
Run Code Online (Sandbox Code Playgroud)
但我不知道它为什么修复它以及它可能有什么副作用。与“经典”路由的唯一区别在于它位于命名的路由器插座上。
我尝试在我的组件中执行以下操作 changeDetection: ChangeDetectionStrategy.OnPush,
@ViewChild('searchInput') input: ElementRef;
ngAfterViewInit() {
this.searchText$ = fromEvent<any>(this.input.nativeElement, 'keyup')
.pipe(
map(event => event.target.value),
startWith(''),
debounceTime(300),
distinctUntilChanged()
);
}
Run Code Online (Sandbox Code Playgroud)
并在模板中
<div *ngIf="searchText$ | async as searchText;">
results for "<b>{{searchText}}</b>"
</div>
Run Code Online (Sandbox Code Playgroud)
它不起作用,但是如果我删除OnPush,它会起作用。我不太确定为什么因为异步管道应该触发更改检测。
编辑:
根据答案,我尝试用以下内容替换我所拥有的内容:
this.searchText$ = interval(1000);
Run Code Online (Sandbox Code Playgroud)
没有任何@Input,async管道正在标记我的组件进行检查,它工作得很好。所以我不明白为什么我没有和fromEvent