Angularjs: Html value from string variable

Behlül

I have an application in which the value of an html element comes from server as a template. I'm trying to assign this template, which is basically a string and get the variables in template bound to controller but angular doesn't bind the variables.

To be more clear, I have a textarea like this

  <textarea class="someclass" placeholder="${fbPostData.name}"
            ng-model="fbPostMessage">
  </textarea>

In my controller, I assign fbPostMessage to be:

$scope.fbPostMessage = "Join {{userFirstName}}. Subscribe today to have fun!"

After these steps in my view I don't see the variables replaced with their values, userFirstName is not replaced by its value.

I've tried $compile and it gave error. It probably expects html tags. How can I achieve what I want?

Arun

Instead of compile use interpolate to compile your before it display.

$scope.userFirstName = "Hello";
$scope.fbPostData={
   name : "Placeholder"
}
$scope.fbPostMessage = $interpolate("Join {{userFirstName}}. Subscribe  today to have fun!")($scope)

Try this example

http://plnkr.co/edit/uqpe32Gy0IfxWGLoPdLX?p=preview

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

printing a value from a string variable

From Dev

Generate HTML string from AngularJS template string

From Dev

Pass value from CodeBehind to Angularjs variable

From Dev

AngularJS - Get $scope variable from string

From Dev

AngularJS - Get $scope variable from string

From Dev

Pass a variable from controller to html in angularjs

From Dev

Load HTML template from file into a variable in AngularJs

From Dev

How to change angularjs variable from html

From Dev

How to set/call angularJS variable from HTML

From Dev

Concatenate object value to the string variable in html template

From Dev

How to show HTML with AngularJS from JSON string

From Dev

Remove HTML tag from string in AngularJS

From Dev

How to store value from datepicker into string variable

From Dev

Get value from string representing local variable

From Dev

How to store value from datepicker into string variable

From Dev

Evaluate variable value from string dynamically

From Dev

Take particular value from the variable having html

From Dev

Parse specific string from variable HTML result

From Dev

python, get variable value from string and variable concatination

From Dev

default value of variable in angularjs

From Dev

Extracting a value from a HTML string (PYTHON)

From Dev

Extracting a value from a HTML string (PYTHON)

From Dev

Get ID value from html string

From Dev

Variable value not being rendered in the view from controller angularjs

From Dev

Access variable by string in AngularJS

From Dev

AngularJS variable not showing in html

From Dev

angularJs variable to Html

From Dev

How can I evaluate a variable from an AngularJS controller inside an html?

From Dev

Comparing a variable defined from angularJS controller in HTML page

Related Related

  1. 1

    printing a value from a string variable

  2. 2

    Generate HTML string from AngularJS template string

  3. 3

    Pass value from CodeBehind to Angularjs variable

  4. 4

    AngularJS - Get $scope variable from string

  5. 5

    AngularJS - Get $scope variable from string

  6. 6

    Pass a variable from controller to html in angularjs

  7. 7

    Load HTML template from file into a variable in AngularJs

  8. 8

    How to change angularjs variable from html

  9. 9

    How to set/call angularJS variable from HTML

  10. 10

    Concatenate object value to the string variable in html template

  11. 11

    How to show HTML with AngularJS from JSON string

  12. 12

    Remove HTML tag from string in AngularJS

  13. 13

    How to store value from datepicker into string variable

  14. 14

    Get value from string representing local variable

  15. 15

    How to store value from datepicker into string variable

  16. 16

    Evaluate variable value from string dynamically

  17. 17

    Take particular value from the variable having html

  18. 18

    Parse specific string from variable HTML result

  19. 19

    python, get variable value from string and variable concatination

  20. 20

    default value of variable in angularjs

  21. 21

    Extracting a value from a HTML string (PYTHON)

  22. 22

    Extracting a value from a HTML string (PYTHON)

  23. 23

    Get ID value from html string

  24. 24

    Variable value not being rendered in the view from controller angularjs

  25. 25

    Access variable by string in AngularJS

  26. 26

    AngularJS variable not showing in html

  27. 27

    angularJs variable to Html

  28. 28

    How can I evaluate a variable from an AngularJS controller inside an html?

  29. 29

    Comparing a variable defined from angularJS controller in HTML page

HotTag

Archive