angular2 - ngModel不在标签上工作(ng2-bootstrap,paper-kit)

时间:2016-09-27 09:25:44

标签: angular ng2-bootstrap angular2-ngmodel

对我来说, // Implementing the delete and move to function override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { let moveAction = UITableViewRowAction(style: .Default, title: "Move") { (action, indexPath) in let moveMenu = UIAlertController(title: nil, message: "Move to", preferredStyle: .ActionSheet) // I need to write two handler to handle the movements let cancelationAction = UIAlertAction(title: "Move to Cancelation List", style: .Default, handler: { (action: UIAlertAction) in self.performSegueWithIdentifier("MoveToCancelationList", sender: tableView.cellForRowAtIndexPath(indexPath)) }) let achievementAction = UIAlertAction(title: "Move to Achievement List", style: .Default, handler: { (action: UIAlertAction) in self.performSegueWithIdentifier("MoveToAchievementList", sender: tableView.cellForRowAtIndexPath(indexPath)) }) let cancel = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) moveMenu.addAction(cancelationAction) moveMenu.addAction(achievementAction) moveMenu.addAction(cancel) self.presentViewController(moveMenu, animated: true, completion: nil) } let deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action, indexPath) in // delete items from data source self.wishListBand.removeAtIndex(indexPath.row) self.saveWishListBand() self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) } moveAction.backgroundColor = UIColor.lightGrayColor() deleteAction.backgroundColor = UIColor.redColor() return [moveAction, deleteAction] } 不适用于用于重新设置默认HTML5表单控件的标签,更准确地说是单选按钮。目标是使用这些更改默认输入无线电的值。我目前使用ng2-bootstrap,但也试过了纸质工具包(http://www.creative-tim.com/live/paper-kit)。

使用ng2-bootstrap(https://valor-software.com/ng2-bootstrap/#/buttons

的记录用法时
[(ngModel)]="foo"

我收到此错误:

<label class="btn btn-primary" name="test" [(ngModel)]="foo" btnRadio="foo">foo</label>

可以使用标签中的core.umd.js:3468 Error: Uncaught (in promise): Error: No value accessor for form control with name: 'test' at resolvePromise (zone.js:429) at zone.js:465 at ZoneDelegate.invokeTask (zone.js:236) at Object.onInvokeTask (core.umd.js:6233) at ZoneDelegate.invokeTask (zone.js:235) at Zone.runTask (zone.js:136) at drainMicroTaskQueue (zone.js:368) at XMLHttpRequest.ZoneTask.invoke (zone.js:308) 属性修复此问题,但ngDefaultControl仍被忽略且不会传播。使用纸质套件时会出现同样的问题。

它适用于普通的单选按钮,没有任何问题。

1 个答案:

答案 0 :(得分:0)

您需要将imports添加到要使用它们的模块的@NgModule({ imports: [ButtonsModule], declarations: [...], ... }) export class MyModule {}

    import {Component} from '@angular/core';

    @Component({
    selector: 'my-app',
    template: '<h1>Display something</h1>' // <------
    })
    export class AppComponent {}