0

How to return result in HTML template from fnuction Angular JS?

HTML:

<div>{{getName({{type}})}}</div>

Angular JS:

$scope.getName = function (type){
  return 'Bob';
}

I need to get Bob in DIV element

0

2 Answers 2

4

Remove the second pair of curly braces. {{getName(type)}} is sufficient.

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

Comments

-1

As you didn't give the type parameter any value. So I just pass it 1

Try this:

{{getName(1)}}

7 Comments

This is not the cause for the problem.
I know the problem is only the braces. I just say that I passed 1 as the parameter for testing purpose
Still this is not the cause of the problem. The snippet is not the whole document. And you cannot assume that type is not definied. Even if it is not defined, angulars interpolations are forgiving, meaning that still Bob would be displayed.
It is, but where in your answer do you mention that? Nowhere. So this answer is NOT useful and does NOT fulfill the needs of an answer.
Though not mentioned I have given the code. You could have suggested me to explain that instead or could be edited
|

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.