小编Sci*_*ion的帖子

Angular6什么是浏览器目标

这是一个标准的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...

angular angular6

6
推荐指数
1
解决办法
965
查看次数

当使用带有查询字符串的url时,Angularjs返回按钮不起作用

这是我的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之前来自字符串查询.如何修复后退按钮以使其处理字符串查询?

router angularjs angular-ui-router

5
推荐指数
0
解决办法
745
查看次数

在SASS参数面前散列

我想知道之间的区别是什么:

@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)

在争论面前有#的目的是什么?

css sass

5
推荐指数
1
解决办法
549
查看次数

Angular2:组件输入中的转义字符

我有以下代码:

<my-comp [title]="Foo's component"></my-comp>
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多东西(''\'\\'\'',...)逃避',但是我没能做到这一点。我怎样才能做到这一点 ?

angular

5
推荐指数
1
解决办法
2119
查看次数

Angular 4如何注入svg

我一直在标签中使用svg或作为背景图像.最近关注:https://css-tricks.com/using-svg/ 我想直接注入我的svg.Angular4有任何功能允许吗?

svg angular

5
推荐指数
1
解决办法
6208
查看次数

Angular4 区别 componentInstance 和 debugElement.componentInstance

我刚刚浏览了那边的文档https://angular.io/guide/testing

component = fixture.debugElement.componentInstance
component = fixture.componentInstance
Run Code Online (Sandbox Code Playgroud)

但我还没有理解这两者之间的区别

testing angular

5
推荐指数
1
解决办法
1543
查看次数

Angular4 如何以一种急切的方式加载模块

在 Angular4 中,您可以使用loadChildren路由配置中的属性延迟加载模块pathToMyModule#MyModule。我想知道是否可以指定任何属性来始终加载我的模块(因此基本上禁用延迟加载)。

angular

5
推荐指数
1
解决办法
4064
查看次数

在网站和 InAppBrowser 之间进行通信

我有一个启动 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)

javascript cordova

5
推荐指数
0
解决办法
209
查看次数

Angular:路由器导航抛出 JIT 编译失败

在 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)

但我不知道它为什么修复它以及它可能有什么副作用。与“经典”路由的唯一区别在于它位于命名的路由器插座上。

javascript typescript angular

5
推荐指数
0
解决办法
245
查看次数

Angular - RxJS:afterViewInit 和异步管道

我尝试在我的组件中执行以下操作 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)

没有任何@Inputasync管道正在标记我的组件进行检查,它工作得很好。所以我不明白为什么我没有和fromEvent

javascript rxjs typescript angular

5
推荐指数
1
解决办法
897
查看次数