Hi there,
I have a directive which will change it's width based on it's parent's size.
I'd like to unit test this, but it looks like the parent element doesn't have a
width in my unit test. Notes: phantomjs, jquery, ng 1.2.13.
Below is the method invoked from the directive's template:
scope.adjustBar = function(barName, delta) {
var bar = elem.find('.' + barName + ' .progress-bar'),
width = bar.width(),
parentWidth = bar.parent('.progress').width();
console.log('Parent width is: ' + parentWidth);
bar.css('width', (((width += delta) / parentWidth) * 100) + '%');
};
Below is the HTML:
<div class="a-parent">
<button class="btn decrease"
data-ng-click="adjustBar('a-parent', -10)">Decrease</button>
<div class="progress">
<div class="progress-bar progress-bar-success"
role="progressbar"
aria-valuenow="50"
aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">50% Complete</span>
</div>
</div>
<button class="btn increase"
data-ng-click="adjustBar('a-parent', 10)">Increase</button>
</div>
What do you think?
Raul
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.