Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng重复上的随机高度_Javascript_Angularjs - Fatal编程技术网

Javascript ng重复上的随机高度

Javascript ng重复上的随机高度,javascript,angularjs,Javascript,Angularjs,我想要随机高度的潜水艇。但是,ng样式中的随机高度函数只调用一次,并将相同的随机高度应用于所有div 这是我的html: <div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox" ng-click="loadDetails(result.myId)"> <div ng-style="setImage(result.miThumbnail)"></div>

我想要随机高度的潜水艇。但是,ng样式中的随机高度函数只调用一次,并将相同的随机高度应用于所有div

这是我的html:

<div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox" ng-click="loadDetails(result.myId)">
    <div ng-style="setImage(result.miThumbnail)"></div>
    <h5>{{result.name}}</h5>
</div>

问题是您的
$scope.randomHeight(200)
只运行一次,并反复使用。尝试将
$scope.resultBox
转换为函数

$scope.resultBox = function(){ 

        return {
            backgroundColor:'#ff0000',
            height: $scope.randomHeight(200)+'px',
            position:'relative',
            textAlign:'center',
            verticalAlign:'top',
            width:'260px',
            display:'inline-block',
            margin:'10px',
            borderRadius:'5px'
        };

       }
同时更改html以调用此函数:
ng style=“resultBox()”


问题在于您的
$scope.randomHeight(200)
只运行一次,并反复使用。尝试将
$scope.resultBox
转换为函数

$scope.resultBox = function(){ 

        return {
            backgroundColor:'#ff0000',
            height: $scope.randomHeight(200)+'px',
            position:'relative',
            textAlign:'center',
            verticalAlign:'top',
            width:'260px',
            display:'inline-block',
            margin:'10px',
            borderRadius:'5px'
        };

       }
同时更改html以调用此函数:
ng style=“resultBox()”


问题在于您的
$scope.randomHeight(200)
只运行一次,并反复使用。尝试将
$scope.resultBox
转换为函数

$scope.resultBox = function(){ 

        return {
            backgroundColor:'#ff0000',
            height: $scope.randomHeight(200)+'px',
            position:'relative',
            textAlign:'center',
            verticalAlign:'top',
            width:'260px',
            display:'inline-block',
            margin:'10px',
            borderRadius:'5px'
        };

       }
同时更改html以调用此函数:
ng style=“resultBox()”


问题在于您的
$scope.randomHeight(200)
只运行一次,并反复使用。尝试将
$scope.resultBox
转换为函数

$scope.resultBox = function(){ 

        return {
            backgroundColor:'#ff0000',
            height: $scope.randomHeight(200)+'px',
            position:'relative',
            textAlign:'center',
            verticalAlign:'top',
            width:'260px',
            display:'inline-block',
            margin:'10px',
            borderRadius:'5px'
        };

       }
同时更改html以调用此函数:
ng style=“resultBox()”

尝试使用以下功能:

<div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox()" ng-click="loadDetails(result.myId)">
    <div ng-style="setImage(result.miThumbnail)"></div>
    <h5>{{result.name}}</h5>
 </div>
尝试使用以下函数:

<div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox()" ng-click="loadDetails(result.myId)">
    <div ng-style="setImage(result.miThumbnail)"></div>
    <h5>{{result.name}}</h5>
 </div>
尝试使用以下函数:

<div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox()" ng-click="loadDetails(result.myId)">
    <div ng-style="setImage(result.miThumbnail)"></div>
    <h5>{{result.name}}</h5>
 </div>
尝试使用以下函数:

<div id = "{{result.myId}}"ng-repeat="result in results" ng-style = "resultBox()" ng-click="loadDetails(result.myId)">
    <div ng-style="setImage(result.miThumbnail)"></div>
    <h5>{{result.name}}</h5>
 </div>

非常感谢。旁白:由于高度是随机的,所以边距之间的间隙保持不变,我如何调整边距间隙open@William猎鹰:根据随机高度调整你的
边距:'10px'
。由于这是一个函数,您可以执行类似于
var height=$scope.randomHeight(200)
的操作,并使用该高度计算边距。(如果这是你需要的)谢谢。旁白:由于高度是随机的,所以边距之间的间隙保持不变,我如何调整边距间隙open@William猎鹰:根据随机高度调整你的
边距:'10px'
。由于这是一个函数,您可以执行类似于
var height=$scope.randomHeight(200)
的操作,并使用该高度计算边距。(如果这是你需要的)谢谢。旁白:由于高度是随机的,所以边距之间的间隙保持不变,我如何调整边距间隙open@William猎鹰:根据随机高度调整你的
边距:'10px'
。由于这是一个函数,您可以执行类似于
var height=$scope.randomHeight(200)
的操作,并使用该高度计算边距。(如果这是你需要的)谢谢。旁白:由于高度是随机的,所以边距之间的间隙保持不变,我如何调整边距间隙open@William猎鹰:根据随机高度调整你的
边距:'10px'
。由于这是一个函数,您可以执行类似于
var height=$scope.randomHeight(200)
的操作,并使用该高度计算边距。(如果这是您需要的)