-
ng
- function
- angular.UNSAFE_restoreLegacyJqLiteXHTMLReplacement
- angular.bind
- angular.bootstrap
- angular.copy
- angular.element
- angular.equals
- angular.errorHandlingConfig
- angular.extend
- angular.forEach
- angular.fromJson
- angular.identity
- angular.injector
- angular.isArray
- angular.isDate
- angular.isDefined
- angular.isElement
- angular.isFunction
- angular.isNumber
- angular.isObject
- angular.isString
- angular.isUndefined
- angular.merge
- angular.module
- angular.noop
- angular.reloadWithDebugInfo
- angular.toJson
- directive
- a
- form
- input
- input[checkbox]
- input[date]
- input[datetime-local]
- input[email]
- input[month]
- input[number]
- input[radio]
- input[range]
- input[text]
- input[time]
- input[url]
- input[week]
- ngApp
- ngBind
- ngBindHtml
- ngBindTemplate
- ngBlur
- ngChange
- ngChecked
- ngClass
- ngClassEven
- ngClassOdd
- ngClick
- ngCloak
- ngController
- ngCopy
- ngCsp
- ngCut
- ngDblclick
- ngDisabled
- ngFocus
- ngForm
- ngHide
- ngHref
- ngIf
- ngInclude
- ngInit
- ngJq
- ngKeydown
- ngKeypress
- ngKeyup
- ngList
- ngMaxlength
- ngMinlength
- ngModel
- ngModelOptions
- ngMousedown
- ngMouseenter
- ngMouseleave
- ngMousemove
- ngMouseover
- ngMouseup
- ngNonBindable
- ngOn
- ngOpen
- ngOptions
- ngPaste
- ngPattern
- ngPluralize
- ngProp
- ngReadonly
- ngRef
- ngRepeat
- ngRequired
- ngSelected
- ngShow
- ngSrc
- ngSrcset
- ngStyle
- ngSubmit
- ngSwitch
- ngTransclude
- ngValue
- script
- select
- textarea
- object
- angular.version
- type
- $cacheFactory.Cache
- $compile.directive.Attributes
- $rootScope.Scope
- ModelOptions
- angular.Module
- form.FormController
- ngModel.NgModelController
- select.SelectController
- provider
- $anchorScrollProvider
- $animateProvider
- $compileProvider
- $controllerProvider
- $filterProvider
- $httpProvider
- $interpolateProvider
- $locationProvider
- $logProvider
- $parseProvider
- $qProvider
- $rootScopeProvider
- $sceDelegateProvider
- $sceProvider
- $templateRequestProvider
- service
- $anchorScroll
- $animate
- $animateCss
- $cacheFactory
- $compile
- $controller
- $document
- $exceptionHandler
- $filter
- $http
- $httpBackend
- $httpParamSerializer
- $httpParamSerializerJQLike
- $interpolate
- $interval
- $jsonpCallbacks
- $locale
- $location
- $log
- $parse
- $q
- $rootElement
- $rootScope
- $sce
- $sceDelegate
- $templateCache
- $templateRequest
- $timeout
- $window
- $xhrFactory
- filter
- currency
- date
- filter
- json
- limitTo
- lowercase
- number
- orderBy
- uppercase
- auto
- ngAnimate
- ngAria
- ngComponentRouter
- ngCookies
-
ngMessageFormat
- ngMessages
-
ngMock
- object
- angular.mock
- service
- $animate
- $componentController
- $controller
- $exceptionHandler
- $flushPendingTasks
- $httpBackend
- $interval
- $log
- $timeout
- $verifyNoPendingTasks
- provider
- $exceptionHandlerProvider
- type
- $rootScope.Scope
- angular.mock.TzDate
- function
- angular.mock.dump
- angular.mock.inject
- angular.mock.module
- angular.mock.module.sharedInjector
- browserTrigger
- ngMockE2E
-
ngParseExt
- ngResource
- ngRoute
- ngSanitize
- ngTouch
ngBind
- - directive in module ng
Overview
The ngBind
attribute tells AngularJS 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 preferable to use ngBind
instead of {{ expression }}
if a template is momentarily
displayed by the browser in its raw state before AngularJS 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.
Directive Info
- This directive executes at priority level 0.
Usage
- as attribute:
<ANY ng-bind="expression"> ... </ANY>
- as CSS class:
<ANY class="ng-bind: expression;"> ... </ANY>
Arguments
Param | Type | Details |
---|---|---|
ngBind | expression |
Expression to evaluate. |
Example
Enter a name in the Live Preview text box; the greeting below the text box changes instantly.
<script>
angular.module('bindExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.name = 'Whirled';
}]);
</script>
<div ng-controller="ExampleController">
<label>Enter name: <input type="text" ng-model="name"></label><br>
Hello <span ng-bind="name"></span>!
</div>
it('should check ng-bind', function() {
var nameInput = element(by.model('name'));
expect(element(by.binding('name')).getText()).toBe('Whirled');
nameInput.clear();
nameInput.sendKeys('world');
expect(element(by.binding('name')).getText()).toBe('world');
});