String Expression in AngularJS with Examples

Here we will learn what are the string expressions in angularjs and how to use string expressions in angularjs with example.

String Expressions in AngularJs

The string expression in angularjs is a unit of code to perform operations on string values. We will see how to use string expressions in angularjs with example

Example of String Expressions in AngularJS

Create or add a HTML page (say index.html) in your application. After adding the index.html page add the following sample code of angularjs string expressions in the header section of your page. 

To get in-Depth knowledge on Angularjs you can enroll for a live demo on Angularjs Online Training

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<script type="text/javascript">

var app = angular.module('expressionApp', [])

app.controller("expressionController", function ($scope) {

$scope.expression1 = "Welcome to ";

$scope.expression2 = "Tutlane.com"

});

</script>

Write the following code under starting of body tag <body> for string expression in angularjs like as shown below.

Take your career to new heights of success with Angular Training

<body ng-app="expressionApp">

<form id="form1">

<div ng-controller="expressionController">

<div>String  Expression</div>

<p>Hello: {{expression1+" "+expression2}}</p>

</div>

</form>

</body>

Following is the full example code for string expressions in angularjs with live demo as show below

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>String Expressions of AngularJs</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<script type="text/javascript">

var app = angular.module('expressionApp', [])

app.controller("expressionController", function ($scope) {

$scope.expression1 = "Welcome to ";

$scope.expression2 = "Tutlane.com"

});

</script>

</head>

<body ng-app="expressionApp">

<form id="form1">

<div ng-controller="expressionController">

<div>String  Expression</div>

<p>Hello: {{expression1+" "+expression2}}</p>

</div>

</form>

</body>

</html>

Now run above code of string expressions in angularjs example and check output that will be like as shown below

Output of AngularJS String Expressions

Following is the result of angularjs string expressions example

Angularjs string expressions example output or result

To learn more about String Expression in AngularJS and other great features of AngularJS , you can enroll for a live demo on Angular Online Training

Published by sindhuja cynixit

i am working as a digital marketing executive

Leave a comment

Design a site like this with WordPress.com
Get started