Questions tagged [ng-bind]

The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes. Typically, you don't use ngBind directly, but instead you use the double curly markup like {{ expression }} which is similar but less verbose.

Source: http://docs.angularjs.org/api/ng.directive:ngBind

The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes.

Typically, you don't use ngBind directly, but instead you use the double curly markup like {{ expression }} which is similar but less verbose.

It is preferrable to use ngBind instead of {{ expression }} when a template is momentarily displayed by the browser in its raw state before Angular compiles it. Since ngBind is an element attribute, it makes the bindings invisible to the user while the page is loading.

An alternative solution to this problem would be using the ngCloak directive.

Usage

as attribute

<ANY ng-bind="{expression}">
   ...
</ANY>

as class

<ANY class="ng-bind: {expression};">
   ...
</ANY>
  • Parameters

    ngBind – {expression} – Expression to evaluate.

183 questions
3
votes
1 answer

AngularJS: Is there a convenient way to show and bind on an element if value is defined?

I am looking for one line syntax for this: {{value}} Maybe something like:
Trantor Liu
  • 8,770
  • 8
  • 44
  • 64
2
votes
1 answer

Change ng-model inside of ng-repeat loop

I'm trying to bind ng-model to input basing on $index of ng-repeat or key of object which I'm looping on. I tried like this
BT101
  • 3,666
  • 10
  • 41
  • 90
2
votes
2 answers

How to render the contents of angular variables inside ng-bind-html

I'm taking a HTML content to the front end javascript code, from the database which was saved as varchar. It is stored in a variable called vm.htmlContent And then I want to display this string type HTML content again as HTML in my web page. I use…
user6534695
2
votes
1 answer

How to retrieve value for ng-bind locator in protractor?

The code line is: class="ng-binding ng-scope" ng-bind="item.name">Soap Its a drop down and I want to select the value 'soap'.
Rozmeen Ali
  • 107
  • 1
  • 10
2
votes
1 answer

How to bind inner html to angular1 elements with ng-bind attribute

inner html
Does anyone know how to display the inner div? Seems the ng-bind directive will always rewrite div element. Thanks in advance.
Chen Dachao
  • 1,736
  • 2
  • 21
  • 36
2
votes
1 answer

How does ng-bind and ng-bind-html prevent XSS?

I have been trying to study XSS on Angular JS and found that ng-bind and ng-bind-html prevents XSS against arbitrary user input which has already been encoded by html-encode in server site. How exactly does this work ? Is there any way to by pass…
2
votes
1 answer

default text when the input is empty in angular for label while binding

I have this piece of code that is working fine and displays the data as per received from controller into the binding. However, I tried to make server data as string.empty and I was expecting this default text "Your name" would appear, and it is…
Jasmine
  • 5,186
  • 16
  • 62
  • 114
2
votes
1 answer

ng-binding is not working but ng-model works

I am learning to use Angular (1.3.10), I have two input fields that specify the suit and value for a hand of playing card. As you can see from the image below, when I try to hardcode the suit and value, the card shows up fine (one on the right). But…
user6758349
2
votes
1 answer
2
votes
3 answers

In Angular use ng-bind in class

In Angular I can write next : class="{{ DayTypesClasses[request.typeId] }}" which will set css-class according to expression value But I've found that ng-bind can make the same but also save some time for this binding. I've tried to use ng-bind…
demo
  • 6,038
  • 19
  • 75
  • 149
2
votes
2 answers

Input a number and showed it in 'hh:mm:ss' /time format in AngularJS

Im making function in my app that when I entered a specific number, It will display the in hh:mm:ss format and start counting down. The input number will be treated as minutes for example when I input 2, the display would be 00:02:00 then it will…
bleyk
  • 799
  • 3
  • 14
  • 41
2
votes
1 answer

ng-bind not updating after closing modal form

I have a view with one list item. After user clicked on this item, the modal form show. When user change value and close modal, the item-not not updating. View:
mreoer
  • 109
  • 1
  • 12
2
votes
1 answer

ng-bind failing when using a custom filter

I've looked through a number of responses and can't for the life of me figure out why my code isn't working! I want to apply a simple custom filter to a variable passed from the controller. The room-price value displays fine. however, when I add…
Alistair Colling
  • 1,363
  • 2
  • 19
  • 29
2
votes
1 answer

AngularJs + Pubnub data binding

I use the PubNub+AngularJS script file provided by Pubnub. I have a controller that sets up the channels and subscribes to it. I set the scope variable in the callback function, and I see the value being updated in the scope function. The problem is…
leo
  • 1,423
  • 2
  • 14
  • 23
2
votes
1 answer

How to control the view based on the value selected from drop down in AngularJs?

My Json data is : [{ "objective": "My obj", "score": 9, "status": "active", "quarter": "Q1", "year": "2015", "team": "A", "owner_ids": [ "175323" ], "key_results": [{ "result": "resut11", …
Mr X
  • 1,637
  • 3
  • 29
  • 55
1 2
3
12 13