什么是在angular.dart中使用select指令的正确方法 [英] What is right way to use select directive in angular.dart

查看:292
本文介绍了什么是在angular.dart中使用select指令的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用基本的CRUD操作扩展angular.dart.tutorial。因此,在新的edit_recipe_component.html中,我需要为食谱类别添加一些选择输入。



目前我有



< pre class =lang-html prettyprint-override> < select ng-model =ctrl.recipe.category>
< option ng-repeat =c in ctrl.categoriesvalue ={{c}}> {{c}}< / option>< / select&

在表面上工作得很好:我可以从列表中选择类别,在模型等。
但是我在调​​试控制台中遇到这些错误:

  NoSuchMethodError:未找到方法:'ngValue'
接收者:null
参数:[]

STACKTRACE:
#0 Object.noSuchMethod(dart:core-patch / object_patch.dart:42)
#1 _SingleSelectMode .onModelChange。< anonymous closure> (package:angular / directive / input_select.dart:185:78)
#2 _SelectMode._forEachOption(package:angular / directive / input_select.dart:146:24)
#3 _SingleSelectMode.onModelChange :angular / directive / input_select.dart:183:19)

我做错了什么? / p>

不幸的是 APIDOCS到InputSelectDirective 没有使用部分



更新:我创建了github第6章样例,问题转载了
它在这里: https://github.com/vadimtsushko/angular_tutorial_chapter_06



一些调试显示编辑表单中的设置类别立即并成功工作(我已在食谱列表视图中添加了类别以进行调试)。
当我离开编辑表单时出错。

解决方案

我认为这个问题已经修复了一段时间不需要补丁),但在任何情况下,您也可以使用 ng-value

 < select ng-model =ctrl.recipe.category> 
< option ng-repeat =c in ctrl.categoriesng-value =c> {{c}}< / option>< / select&


I extend angular.dart.tutorial with basic CRUD operations. So in new edit_recipe_component.html I need to add some sort of selection input for recipe categories.

Currently I have

<select ng-model="ctrl.recipe.category">
   <option ng-repeat="c in ctrl.categories" value="{{c}}">{{c}}</option></select>

That works perfectly well on the surface: I can select category from the list, selected category is successfully stored in model and so on. But I get these errors in debug console:

NoSuchMethodError : method not found: 'ngValue'
Receiver: null
Arguments: []

STACKTRACE:
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      _SingleSelectMode.onModelChange.<anonymous closure> (package:angular/directive/input_select.dart:185:78)
#2      _SelectMode._forEachOption (package:angular/directive/input_select.dart:146:24)
#3      _SingleSelectMode.onModelChange (package:angular/directive/input_select.dart:183:19)

What I'm doing wrong?

Unfortunately APIDOCS to InputSelectDirective has no usage section

Update: I've created github project based on Chapter 6 sample where problem is reproduced It is here: https://github.com/vadimtsushko/angular_tutorial_chapter_06

Some debugging shows that setting category in Edit form works immediately and successfully (I've added category in Recipes list view for debug purpose). Error raised when I leave Edit form.

解决方案

I believe that this issue has been fixed for a while (hence no need for a patch), but in any case, you could also have used ng-value:

<select ng-model="ctrl.recipe.category">
   <option ng-repeat="c in ctrl.categories" ng-value="c">{{c}}</option></select>

这篇关于什么是在angular.dart中使用select指令的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆