4

My markup was:

<input char-limit="10" />

Then I needed to set the attribute value from controller, so I did this:

 <input char-limit="{{charLimit}}" />

And in controller:

$scope.charLimit = <my value>;

Now, instead of using the model value directly; I need to use the function to return the value. So I did:

<input char-limit="getCharLimit()" />

And in controller:

$scope.getCharLimit= function(){
 return <my value>;
}

But the value is not reflected in the markup.

asked Aug 7, 2015 at 6:48

2 Answers 2

6

You need to enclose the function inside of curly braces

<input char-limit="{{getCharLimit()}}" />
answered Aug 7, 2015 at 6:51
Sign up to request clarification or add additional context in comments.

1 Comment

Oops, what a dumb mistake! Thanks, will accept the answer after 10 minutes.
1

Typically an Angular Expression must be enclosed within {{ }}

{{ expression }}

So the correct one should be : <input char-limit="{{getCharLimit()}}" />

answered Aug 7, 2015 at 7:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.