【发布时间】:2016-10-20 13:01:25
【问题描述】:
我正在尝试使用 jQuery.matchHeight 将元素设置为相同的高度。我从 Angular 指令调用函数
angular.module('myApp')
.directive('matchHeight', ['$timeout', function ($timeout) {
var linkFunction = function(scope, element) {
$timeout(function() {
angular.element(element).matchHeight();
});
};
return {
restrict: 'A',
link: linkFunction
};
}]);
matchHeight 插件和 jQuery 包含在 index.html 中
<html>
<head>
all head stuff
</head>
<body>
<div class="row usps">
<div class="col-sm-4 usp-block" ng-repeat="block in content.marketing" match-height>
<a href="{{block.link_url}}" class="thumbnail">
// Rest of html
</a>
</div>
</div>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/matchHeight/dist/jquery.matchHeight.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/directives/matchheight.js"></script>
</body>
</html>
问题是虽然指令被应用于元素,但高度没有设置。
【问题讨论】:
标签: javascript jquery angularjs angularjs-directive angularjs-controller