0

I have the following code...

<div> {{line.tab}} </div>

This prints out the number of tabs I want (1, 2, 3) and works fine. Now I need to know how to print the tab char (\t) as many times. I would prefer not to use the controller.

In other word line.tab can be 1, 2, or 3 if it is 1 it should have 0 tabs 2 should have 1, etc.

The only way I have been able to accomplish this so far is using the controller like this (this uses 4 spaces instead of a tab but same idea)...

span(ng-repeat="i in ctrl.getNumber(line.tab) track by $index") &nbsp;&nbsp;&nbsp;&nbsp;
span {{line.n.properties.indicator}}
span {{line.n.properties.e}}
span {{line.n.properties.value}}

controller : function(){
  this.getNumber = function(num) {
    return new Array(num-1);
  }
}

I was hoping to do this without having to use the controller function and without multiple spans.

1
  • Please, add more code. Commented Nov 5, 2015 at 21:16

1 Answer 1

1

You could try

<div ng-repeat="n in [0, 1, 2]">
      &#9
</div>

Here's the doc for ngRepeat https://docs.angularjs.org/api/ng/directive/ngRepeat

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

6 Comments

Eh this won't really work with my DOM I am using a filter for now but I don't like it needed to make sure I had ng-trim="false" though
If so, could you please update the question so that it is more specific? Maybe with an example closer to your real case? Because from your initial question the problem seems trivial.
"Trivial"? But your answer doesn't do a trick, it would just print literally "\t", not tab. Not really what OP is looking. Anyway, you can't print tab in HTML like this, it will be just "\t" two characters, but not tab.
@dfsq Sure, but it's hard to say what exactly OP is looking for from his question. I had an impression he doesn't know "ng-repeat", so i tried to help him with that.
No I do know ng-repeat very well I just didn't want 3 span tags (or in your case div tags) in my DOM. Not to mention if n changes (for example some records are 3 others 2 etc) so this doesn't do what I would need it to in terms of being able to increase in size.
|

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.