小编Ric*_*ich的帖子

未捕获错误:模块'AppModule'导入的意外指令'MyComboBox'.请添加@NgModule注释

我有一个自定义组件(MyComboBox)里面有kendo-combobox.

当我使用我的核心模块时,webpack编译成功结束,但chrome抛出以下错误:

Uncaught Error: Unexpected directive 'MyComboBox' imported by the module 'AppModule'. Please add a @NgModule annotation.
Run Code Online (Sandbox Code Playgroud)

这是我的AppModule:

app.module.ts

import { MyComboBox } from '@my/core/control/MyComboBox';

@NgModule({
    declarations: [
        AppComponent,
        MyComboBox
    ],
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule,
        DragulaModule,
        MyComboBox,
        CoreModule,
        ComboBoxModule
    ],
    entryComponents: [ MyComboBox ],
    providers: [HelperService],
    bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)

kendo-ui typescript webpack angular

37
推荐指数
2
解决办法
6万
查看次数

Angular 2路由重定向到子路由

我是Angular 2的新手.我想为我的应用程序的每个部分创建独立的模块.例如,我使用默认组件AuthComponent创建了AuthModule,其中包含其子组件(SignIn或SignUp)的路由器插座.所以我想实现以下场景:

  1. 导航到/ - root off app - 重定向到/ auth
  2. 重定向到/ auth后 - 用路由器插座加载AuthComponent
  3. 加载AppComponent后 - 通过重定向到/ auth/sign-in加载默认登录组件

但是当我去localhost /我得到重定向到/ auth我想要的东西,但下一次重定向到登录不会出现.

我的代码:app.routing

const routes: Routes = [
  {
      path: '', 
      redirectTo: '/auth', 
      pathMatch: 'full'
  }
];

export const appRouting: ModuleWithProviders = RouterModule.forRoot(routes);
Run Code Online (Sandbox Code Playgroud)

auth.routing

const routes: Routes = [
  {
    path: 'auth',
    component: AuthComponent,
    children: [
      {
         path: '', 
         redirectTo: 'sign-in', 
         pathMatch: 'full'
      },
      {
         path: 'sign-in', 
         component: SignInComponent
      }
    ]
  },

];

export const authRouting: ModuleWithProviders = RouterModule.forChild(routes);
Run Code Online (Sandbox Code Playgroud)

auth.component.html

<div …
Run Code Online (Sandbox Code Playgroud)

routing children angular

29
推荐指数
3
解决办法
4万
查看次数

要包含的文件中的 Visual Studio Code 高级搜索通配符

我正在尝试使用特定的文件名标准为我的所有文件找到一行代码。我试图通过在文件中放置通配符以包含搜索字段来利用Visual Studio Code的高级搜索。但我没能做到这一点。我尝试使用星号(*)符号,但我认为 Visual Studio Code 不接受。所以我尝试在互联网上搜索并通过使用.+找到了这个解决方案; 然而,它仍然什么都不做。

Search Keyword: ICustomMatColumn

files to include:(通配符)viewmodel.ts

在此处输入图片说明

glob visual-studio-code

17
推荐指数
2
解决办法
3803
查看次数

属性'subscribe'在类型'()=> Observable <any>'上不存在

服务文件

import { Observable } from 'rxjs/Rx';
import { Http,Response} from '@angular/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/Map';

@Injectable()
export class VideoService {

   private geturl = '/api/videos';
   constructor(private _http:Http) { }

   getvideos() {
       return this._http.get(this.geturl).map((response:Response) => {
          response.json()
       });
   }
}
Run Code Online (Sandbox Code Playgroud)

这里是subscribe方法显示此错误的位置

import { VideoService } from '../video.service';
import { Component, OnInit } from '@angular/core';
import { Video } from '../video';
import { Observable } from 'rxjs/Observable';


@Component({
    selector: 'app-videocenter',
    templateUrl: './videocenter.component.html',
    styleUrls: ['./videocenter.component.css']
})
export class VideocenterComponent …
Run Code Online (Sandbox Code Playgroud)

observable rxjs typescript angular2-services angular

16
推荐指数
2
解决办法
6万
查看次数

TypeORM getRepository.find() 不包括外键字段

我正在尝试获取包含在 my 中的所有列entity,但我只能获取与其他实体没有任何关系的列。

我使用此代码块将所有行提取到此存储库。

private translationTextRepository = getRepository(TranslationText);

async all(request: Request, response: Response, next: NextFunction) {
    return this.translationTextRepository.find();
}
Run Code Online (Sandbox Code Playgroud)

entity是这个存储库的。

@Entity('TranslationText')
export class TranslationText {

    @PrimaryGeneratedColumn()
    ID: number;

    @Column()
    CreatedBy: string;

    @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
    CreatedDate: Date;

    @Column()
    Status: boolean;

    @Column({ nullable: true, default: null })
    ModifiedBy: string;

    @Column({ type: 'timestamp', nullable: true, default: null })
    ModifiedDate: Date;

    @Column()
    Text: string;

    @ManyToOne((type) => Locale, (locale) => locale.ID)
    @JoinColumn({ name: 'LocaleID' })
    LocaleID: …
Run Code Online (Sandbox Code Playgroud)

orm typeorm ts-node

12
推荐指数
2
解决办法
5888
查看次数

cordovaProject.projectConfig.getFileResources不是一个函数

当我尝试将项目部署到Android Emulator时,我遇到了部署错误.错误说:

cordovaProject.projectConfig.getFileResources is not a function
Run Code Online (Sandbox Code Playgroud)

我试图搜索网并在这里尝试了这个解决方案,但仍然没有运气.有人能帮我吗?谢谢!

PS:系统信息

Visual Studio 2017 Version 15.5.7
Cordova-Android: 6.3.1
Cordova: 8.0.0
Gradle: 4.6
Run Code Online (Sandbox Code Playgroud)

apache android cordova ionic-framework

11
推荐指数
1
解决办法
2372
查看次数

ng-show/ng-if不立即更新dom高度

我有一个很长的div,它是由ng-hide隐藏/显示的.这是一个基于离子演示的示例.

单击按钮以显示或隐藏longDiv.如果您在隐藏或显示页面后尝试立即滚动页面.有时您可以发现即使在longDiv隐藏之后页面也可以向下滚动.有时甚至在longDiv显示后页面也无法向下滚动.但是如果等待几秒钟,然后尝试滚动页面,滚动条可以匹配页面的实际高度.

HTML:

<ion-content ng-controller="controller">
  <button ng-click="test.show_detail=!test.show_detail">{{test.show_detail}}</button>
  <div ng-show='test.show_detail'>
    <div ng-repeat='i in test.list'>
      {{i}}
    </div>
  </div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)

JS:

.controller('controller', function ($scope) {
     $scope.test = {};
     $scope.test.show_detail = true;
     $scope.test.list = [];
     for(i=0; i< 1000; i++){
       $scope.test.list.push(i);
     }
}
Run Code Online (Sandbox Code Playgroud)

如果longDiv中存在复杂的模板内容,则此问题很容易重现.

有什么方法可以避免这个问题吗?

angularjs cordova ionic-framework

8
推荐指数
1
解决办法
2375
查看次数

如何始终以有角度的材质显示滚动条?

因此,目前,我正在使用角度材质及其默认滚动(但我认为这是完美的滚动条),可以用作滚动条的滚动设计。但是,仅在用户尝试滚动页面/ div时才显示滚动。我试图阅读Angular Material的滚动api,但是这里没有可以使用的属性。我overflow-y: scroll当然已经把它放在css上了。任何的想法?谢谢!

html css scrollbar angular-material angular

7
推荐指数
1
解决办法
1227
查看次数

角材料表字母数字排序行为

我在Angular Material Table中遇到问题,虽然从技术上讲是正确的,但是我在想是否还有其他方法可以解决此问题。

让说,我有5码,F1F2F5F9F10

Angular Material Table的升序排序将是,

F1
F10
F2
F5
F9
Run Code Online (Sandbox Code Playgroud)

但我期望它会

F1
F2
F5
F9
F10
Run Code Online (Sandbox Code Playgroud)

我的html代码在这里

<table mat-table [dataSource]="model.financingPurposeList" class="mat-elevation-z8" width="100%">

   <ng-container matColumnDef="code">
       <th mat-header-cell *matHeaderCellDef mat-sort-header> Code </th>
       <td mat-cell *matCellDef="let financingPurpose"> {{financingPurpose.code}} </td>
   </ng-container>

   <ng-container matColumnDef="description">
       <th mat-header-cell *matHeaderCellDef> Description </th>
       <td mat-cell *matCellDef="let financingPurpose"> {{financingPurpose.description}} </td>
   </ng-container>

   <tr mat-header-row *matHeaderRowDef="['code', 'description']; sticky: true"></tr>
   <tr mat-row *matRowDef="let row; columns: ['code', 'description'];" (click)="model.selectedFinancingPurpose.toggle(row)"></tr>

</table>
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

相关链接: …

sorting angular-material angular

7
推荐指数
1
解决办法
507
查看次数

将 Array 参数传递给 SQLiteObject.executeSql()

我试图将一个数组参数传递给 ionic 中 SQLiteObject 的函数 executeSql 以使其作为我的 sql 查询的值。

例如

var sqlQuery: string = "SELECT * FROM Property WHERE ID IN (?) AND Status = ?"
var ids: number[] = [123, 321, 456];
Run Code Online (Sandbox Code Playgroud)

我想把它传到这里,

var db: SQLiteObject
db.executeSql(sqlQuery, [ids, 0])
Run Code Online (Sandbox Code Playgroud)

所以基本上我想将ids 的所有值插入到IN运算符中,并将 0插入到状态中。但我认为 SQL 对它的解释不同。

我试图将它作为字符串传递db.executeSql(sqlQuery, [ids.toString(), 0])以删除不必要的字符等。但它仍然没有返回任何东西。

注意 我知道我需要它来附上一个承诺或其他东西,但我只是将它切片并总结它以删除不必要的代码。谢谢。

sqlite cordova typescript ionic-framework

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