4-6的19分时,修改股票星级后,点击save,可以返回股票信息管理界面,但是马上要自动刷新一次,但是老师视频里却没有刷新。

来源:4-6 改造项目

慕粉5925852

2018-06-28

stock-form.componnent.ts代码

export class StockFormComponent implements OnInit {


  stock:Stock;

  constructor(private routeInfo:ActivatedRoute,private stockService:StockService,private router:Router) { }


  ngOnInit() {

    let stockId = this.routeInfo.snapshot.params['id'];

    this.stock = this.stockService.getStock(stockId);

  }

  cancel(){

    this.router.navigateByUrl("/stock");

  }


  save(){

    this.router.navigateByUrl("/stock");

  }

}

stock-form.component.html代码:

      </div>

    </div>

    <!-- /.box-body -->

    <div class="box-footer">

      <button (click)="cancel()" type="submit" class="btn btn-default">取消</button>

      <button (click)="save()" type="submit" class="btn btn-info pull-right">保存</button>

    </div>

    <!-- /.box-footer -->

  </form>

</div>

卡在这个问题上好几天了,请老师帮我看看,谢谢!

写回答

2回答

JoJo

2018-07-04

把button换成a试下

2
2
木讷25
同求原因。
2018-08-01
共2条回复

木讷25

2018-07-03

const routeConfig: Routes = [

{path:'', redirectTo: '/dashboard', pathMatch: 'full'},

{path: 'dashboard', component: DashboardComponent},

{path: 'stock', component: StockManageComponent},

{path: 'stock/:id', component: StockFormComponent},

]

你的路由配置对吗?

0
1
慕粉5925852
我的路由配置跟你的一样哦! const routeConfig: Routes = [ //重定向路由 {path: '',redirectTo: '/dashboard', pathMatch: 'full'}, {path: 'dashboard', component: DashboardComponent}, {path:'stock/:id',component:StockFormComponent}, {path: 'stock', component:StockManageComponent} ];
2018-07-03
共1条回复

Angular4.0从入门到实战 打造股票管理网站

Angular新特性,教你熟练使用 Angular 和 Typescript 开发组件式单页应用

2683 学习 · 1361 问题

查看课程