Mark Smit
Mark Smit

Reputation: 574

Use style settings in angular js

I am quite new to angular js. And i have no clue where to search for a solution.

I need style settings in my controller. To more perciese i need the width of an element in my controller. I don't think jquery is the right way to go in angular js. What i want is: i want to show the width of an element as a number in another element. So what i want is doing exactly the oposite of ng-style which changes the widht to the content of the textfield.

I searched for binding a model to an element style. But i can't find anything. Am i looking in the right direction? Could someone point me in a right direction please?

Upvotes: 0

Views: 28

Answers (1)

Walter Brand
Walter Brand

Reputation: 689

The right direction would be to use a directive. I would suggest to create a directive that can retrieve the relevant style properties and places those on its scope:

something like this:

directive('checker', function(){
  return {
    restrict : 'A',
    scope : {
        checker : '='
    },
    link: function(scope){
        scope.checker = // set here the css properties that can be linked to a controller
    }
  }
}

Upvotes: 1

Related Questions