0

I'm trying to resize a div with a background image (left) and a variable height description (right), but can't get it to work. Here's the fiddle . I tried several things with/without zepto/jQuery/document.getElementById ... nothing works.

.directive('resize', function () {
  return {
    restrict: 'A',
    scope: {},
    link: function(scope, elem, attrs) {
      elem.height(400);
    }
  };
})
1
  • I'm seeing "no module app" or something similar. To create the module you need to define it with the second, dependency list argument angular.module('app', []) Commented Aug 8, 2013 at 13:53

2 Answers 2

2

You can use jQuery:

jQuery(elem).height(400);

Fiddle

Not too ideal though :(

Sign up to request clarification or add additional context in comments.

Comments

1

If you don't use jQuery, AngularJS implements only a lite version of the framework, jqLite, which doesn't have a height() method. You can see the documentation for the list of the available functions in jqLite.

In your case, for instance, you can simply do:

element.css('height', '400px');

Fiddle

Notice that, as pointed out in the comment, your fiddle wasn't functional. I've corrected that problem.

3 Comments

Ok, works in the fiddle environment. Not within PhoneGap though. I suppose it has something to do with the DOM not to be ready at this stage?
No. The DOM is ready and computed in the link function, at least for the element and his children (see the documentation). The problem is elsewhere, but we can't help you if we can't reproduce it.
Thanks. I'll try to figure out what's wrong then. At least it's working on the Angular-side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.