Dee*_*psy 18 javascript angularjs angularjs-directive ng-repeat
我得到以下代码:
<div ng-repeat="i in placeholders" square class="set-holder {{i.class}}" droppable="{{i.type}}"></div>
Run Code Online (Sandbox Code Playgroud)
我如何让第一个项目有指令bigsquare,而其他项目只有square.
我试过了:
<div ng-repeat="i in placeholders" {{= $first ? 'big' : ''}}square class="set-holder {{i.class}}" droppable="{{i.type}}"></div>
Run Code Online (Sandbox Code Playgroud)
但遗憾的是我的结果是:
<div ng-repeat="i in placeholders" {{= $first ? 'big' : ''}}square class="set-holder test" droppable="3"></div>
Run Code Online (Sandbox Code Playgroud)
又称绑定不会被编译.
Jan*_*Jan 35
你可以使用ng-repeat-start和ng-repeat-end如下:
angular.module('example', [])
.controller('ctrl', function Ctrl($scope) {
$scope.items = [1, 2, 3];
})
.directive('big', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.css('font-size', '30px');
}
};
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="example" ng-controller="ctrl">
<div ng-repeat-start="item in items" ng-if="$first" big>
big item {{item}}
</div>
<div ng-repeat-end ng-if="!$first">
item {{item}}
</div>
</div>Run Code Online (Sandbox Code Playgroud)
文档可以在ng-repeat下找到.
我在矩阵中有大约10000个样本的重复.我的矩阵有1000行和6列.列中的数字范围为0:58,具体取决于样本.
angular.module('example', [])
.controller('ctrl', function Ctrl($scope) {
$scope.items = [1, 2, 3];
})
.directive('big', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.css('font-size', '30px');
}
};
});Run Code Online (Sandbox Code Playgroud)
我想找出是否有重复的样品.我尝试了replicated(),它告诉我哪些行是重复的,但我想查看该行而不必手动返回.有什么建议?