1

i am building a tree structure in angular 4. my issue is i have to start each node at the same level and indent only the name text from the left border. for every node i have got the depth of the node. i want to add a style like this.

<p   style="padding-left : calc_padding(depth)"> some Text </p>

calc_padding(depth){
return depth *5
}

how can i do that.

i have read style sanitizer but could not find how to use it in my case.

i have tried to impliment [style] = "method(depth)" and [style.padding-left] = "method(depth)" but i am unable to get the things done as i have wanted.

Any help in this regard will be appreciated.

1 Answer 1

2

You have to use the style binding like this:

<p [style.paddingLeft.px]="calc_padding(depth)"></p>

If the value returned from calc_padding should be interpreted as pixels

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

Comments

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.