小编Mik*_*571的帖子

在router.navigate之后没有调用ngOnInit

我的Angular应用程序突然没有调用ngOnInit(),router.navigation()这意味着我的组件无法正确加载.我认为这可能是由于我做出的一些改变,但恢复改变并没有解决问题.

正常导航导致组件无法正确加载的示例; 此页面由以下代码列表导航 this.router.navigate(['/result', this.params.data._id]);:

组件未正确加载

重新加载页面,组件正确加载:

组件正确加载

以下是我的一些代码清单,

app.module.ts

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    AppRoutingModule,
    AgGridModule.withComponents(
            [SampleResultButtonComponent]
        ),
    ChartsModule
  ],
  declarations: [
    AppComponent,

    LoginComponent,
    LogoutComponent,
    SignupComponent,

    FilesComponent,
    NavbarComponent,
    ProfileComponent,
    UploadComponent,
    SampleGridApplicationComponent,
    SampleResultButtonComponent,
    AssetGridApplicationComponent,
    ResultComponent,
    ResetPasswordComponent,
    AssetComponentDetailComponent
  ],
  bootstrap: [ AppComponent ],
  entryComponents: [AssetComponentDetailComponent]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)

APP-routing.module.ts

    @Injectable()
export class NoAuthGuard implements CanActivate {
  constructor(private router: Router) {}

  canActivate() {
    const activeUser = Kinvey.User.getActiveUser();
    if (activeUser) {
      return true;
    }

    // Navigate to the …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular-cli angular

9
推荐指数
2
解决办法
2923
查看次数

NSLayoutContraint中的UIView在swift中不符合AnyObject

在这里找到了这个问题和答案然而我得到了错误

Type 'UIView!' does not conform to protocol 'AnyObject'
Run Code Online (Sandbox Code Playgroud)

对于

...
@IBOutlet var mainView: UIView!
@IBOutlet weak var contentView: UIView!
...
NSLayoutConstraint(item: self.contentView, ...`
Run Code Online (Sandbox Code Playgroud)

解除引用视图对象会发生什么事吗?

ios swift

4
推荐指数
1
解决办法
577
查看次数

标签 统计

angular ×1

angular-cli ×1

angular-routing ×1

ios ×1

swift ×1