我试图在复选框上强制单选,类似于html"select"
我有一个简单的html表:
<tr ng-repeat="subscription in entities">
<td>
<input type="checkbox" ng-checked="isChecked(subscription)" ng-click="toggleSelection(subscription)"/>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
然后我有一些简单的控制器函数用于上面的指令:
$scope.isChecked = function(entity) {
return $scope.checkedEntity === entity;
};
$scope.toggleSelection = function(entity) {
entity.checked = !entity.checked;
if (entity.checked) {
$scope.checkedEntity = entity;
} else {
$scope.checkedEntity = null;
}
};
Run Code Online (Sandbox Code Playgroud)
不幸的是它不起作用,我想我刚刚发现了...... ng-click有0优先级,而ng-checked有100.
这个问题有优雅的解决方案吗?
我基本上是在尝试做这样的事情:
interface gen1<T> {
constructor(param: T);
}
interface gen2<T> {
constructor(param: gen1<any>);
}
class genImpl implements gen2<any> {
constructor(param: gen1<any>) {
}
}
Run Code Online (Sandbox Code Playgroud)
但得到错误:
Class 'genImpl' incorrectly implements interface 'gen2<any>'.
Types of property 'constructor' are incompatible.
Type 'Function' is not assignable to type '(param: gen1<any>) => any'.
Type 'Function' provides no match for the signature '(param: gen1<any>): any'.
Run Code Online (Sandbox Code Playgroud)