- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 angularjs,过去 2 天我一直在尝试创建一个 optgroup,同时处理其他一些东西,但我被难住了。我必须创建一个 ng-options,但没有考虑 optgroup,直到我意识到我需要一个。我尝试使用 ng-options 添加它,但它要么完全忽略它,弄乱代码,要么完全忽略选项。
我不知道是否真的可以使用(双)&符号,所以我尝试组合两个 ng-options,但无济于事。此外,我尝试了在 odetocode 中找到的特定代码(这似乎很有前途,但由于其自身有限的结构而无法与我的代码合并)。
我尝试的一切都会破坏我的代码。原始代码如下(我的许多其他 mods 之前的代码),但我也有它的 plunker:
http://plnkr.co/edit/xCLe2GFShUMUlIySPLH9?p=info
HTML
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" href="style.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script>
<script src="script.js"></script>
</head>
<body>
<form name="FORM" ng-controller="appController">
<the-ratings model="review.ratings">
</the-ratings>
</form>
</body>
</html>
JS
(function(){
var app = angular.module('myApp',[]);
app.controller('appController', ['$scope', function($scope) {
$scope.review = {};
$scope.review.ratings = '5 stars';
}])
app.directive('theRatings', function() {
return {
restrict: 'E',
scope: { model: '=' },
template: '<select ng-model="model" ng-options="option.name as option.value for option in options"></select>',
controller: function($scope) {
$scope.options = [
{ name:'test', namegroup: 'Rate the product', value:'test2',valueName: 'NA' },
{ name: '1 star', value: '1 star' },
{ name: '2 stars', value: '2 stars' },
{ name: '3 stars', value: '3 stars' },
{ name: '4 stars', value: '4 stars' },
{ name: '5 stars', value: '5 stars' }
];
}
};
});
})();
最佳答案
不确定您想要按什么对它们进行分组,因此我添加了一个额外的属性type
:
语法:
ng-options="option.name as option.value group by option.type for option in options"
关于angularjs - 在 AngularJS 中添加 optgroups 被证明是很棘手的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24811461/
(这不是关于定理证明,而是关于实践中的测试,例如 quickCheck) 让f一些通用函数 f :: RESTRICTIONS => GENERICS 具有一些“理想的”属性(即不是 hack,是不可
给定数组 arr 和索引数组 ind,以下算法就地重新排列 arr 以满足给定的索引: function swap(arr, i, k) { var temp = arr[i]; arr[i]
我有兴趣创建一个具有运行时间和空间限制的简单数组问题。看来我找到了解决问题的方法。请阅读以下java代码中问题的初始描述注释: /* * Problem: Given two integer ar
我是 isabelle 的新手,并试图证明以下简单的不等式: lemma ineq: "(a::real) > 0 ⟹ a 0 ⟹ b 0" proof have "1/a + 1/b >
是否有任何理论说缓存应该比文件系统更快? 我认为,由于文件系统也使用缓存,因此没有科学证据表明当文件系统的概念有些松散时,我们应该将内容从文件系统移动到诸如 memcache 之类的缓存中——比如下载
我正在做一个证明,我的一个子目标看起来有点像这样: Goal forall (a b : bool) (p: Prop) (H1: p -> a = b) (H2: p), neg
我有定义的归纳类型: Inductive InL (A:Type) (y:A) : list A -> Prop := | InHead : forall xs:list A, InL y (co
我知道 CRC 是一个线性函数,这意味着 CRC(x xor y) = CRC(x) xor CRC(y),但我不知道如何证明 CRC 的这个属性。 有谁有想法吗? 非常感谢! 最佳答案 这通常不是真
我是 Coq 的初学者。 虽然计算机为我验证了证明令人满意,但众所周知,满足 Coq 的证明对人类来说难以阅读。这是一个简单的例子,假设您没有看到任何评论: Theorem add_comm : fo
我试图了解是什么决定了类型参数是否必须是标称的。 虽然 GADT 和类型家族在某种意义上看起来不同,但它们不是“简单容器”,因为它们的实例定义可以“查看”它们的参数,但简单类型是否可以明显需要名义参数
我想使用 function 关键字定义来证明函数定义的正确性。以下是自然数的通常归纳定义上的加法函数的定义: theory FunctionDefinition imports Main begin
我定义了一个 Sygma-Type,如下所示: { R : nat -> nat -> bool | Reflexive R } 我有两个元素 r1 r2 : { R : nat -> nat ->
我有以下数据: new_pairs x y Freq start.latittude start.longitude start.station end.la
出于教育目的,我一直试图通过使用各种语言扩展和单例类型,在 Haskell 中重建《Type-Driven Development with Idris》(即 RemoveElem.idr )一书中的
我定义了一个 Sygma-Type,如下所示: { R : nat -> nat -> bool | Reflexive R } 我有两个元素 r1 r2 : { R : nat -> nat ->
我正在使用Ax DevTools,并且试图弄清楚如何使用相同的构建信息标记多个扫描。现在,我的测试运行如下: class MyTestCase : XCTestCase { func myTest
我正在尝试证明一个函数的正确性,该函数检查数组是否按递增/递减顺序排序或未排序。行为是返回 -1,如果按降序排序,1,如果按升序排序,大小为 1,或包含相同的值,0,如果没有已排序或为空。运行:Fra
我试图证明 Z3(Microsoft 的 SMT 求解器)中的一个归纳事实。我知道 Z3 通常不提供此功能,如 Z3 guide 中所述。 (第 8 节:数据类型),但是当我们限制要证明事实的域时,这
问题已编辑: 如代码中所述,HashSet 和 HashMap 是快速失败的(但这不是保证): void goHashSet() { Set set = new HashSet();
我试图使导航栏中的链接延伸到导航栏的全长。我环顾四周,发现了一些有用的信息,但无法使其正常工作 HTML: To
我是一名优秀的程序员,十分优秀!