小编ads*_*sds的帖子

运行时错误 ng-select-selection-model -

我的目的是使用这个选择

在我的延迟加载模块中我这样做:

imports: [
        CommonModule,
        FormsModule,    
        NgSelectModule        

    ],
    providers: []
Run Code Online (Sandbox Code Playgroud)

模板:

<ng-select [items]="list" [bindLabel]="TIPE" bindValue="id" [(ngModel)]="tipe" (onChange)="changeValue($event)" >
            </ng-select>
Run Code Online (Sandbox Code Playgroud)

当用户走这条路线时,它会在控制台中打印以下错误:

:

 Uncaught (in promise): NullInjectorError: R3InjectorError(AppModule)[InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model]: 
  NullInjectorError: No provider for InjectionToken ng-select-selection-model!
NullInjectorError: R3InjectorError(AppModule)[InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model -> InjectionToken ng-select-selection-model]: 
  NullInjectorError: No provider for InjectionToken ng-select-selection-model!
Run Code Online (Sandbox Code Playgroud)

我不明白为什么,有人可以帮助我吗?

select package.json angular-ngselect angular

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

服务不打印 console.log

我需要在我的 angular 应用程序中创建一个服务,所以我这样做:

@Injectable({
  providedIn: 'root'
})
export class PropertiesNameService  {

  products: string[] = [];

  constructor(private http: HttpClient) {
    console.log('HI');
    this.http.get('****').subscribe(data => {
    //   console.log(data);
   });
  }
}
Run Code Online (Sandbox Code Playgroud)

在我的 app.module 我这样做:

import {PropertiesNameService} from './propertiesName/properties-name.service';
....

providers: [PropertiesNameService],
Run Code Online (Sandbox Code Playgroud)

问题是,当我启动应用程序并打开控制台时,我看不到 "HI" 。我使用 angular 8 任何人都可以帮助我吗?

angular-services angular angular8

0
推荐指数
1
解决办法
414
查看次数