How to concat strings using AngularJS ? Last Updated : 26 Jul, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to concat strings in AngularJS. There are few ways to concat the strings in AngularJS. In this article, we will see 2 of them.Example 1: In the first example, we are using the '+' operator to concat the strings HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function($scope) { $scope.str1 = 'This is '; $scope.str2 = 'GeeksForGeeks'; $scope.res = ''; $scope.join = function() { $scope.res = $scope.str1 + $scope.str2; }; }); </script> </head> <body style = "text-align:center;"> <h1 style = "color:green;"> GeeksForGeeks </h1> <p> How to concat strings in AngularJS </p> <div ng-app = "app"> <div ng-controller = "controller"> str1 - '{{str1}}' <br> str2 - '{{str2}}' <br> <br> <input type = "button" ng-click = "join()" value = "Click Here"> <br> <p>Result = '{{res}}'</p> </div> </div> </body> </html> Output:Example 2: In the second example we will use the standard concat() method for concatenation. HTML <!DOCTYPE HTML> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function($scope) { $scope.str1 = 'This is '; $scope.str2 = 'GeeksForGeeks'; $scope.res = ''; $scope.join = function() { $scope.res = $scope.str1.concat($scope.str2); }; }); </script> </head> <body style = "text-align:center;"> <h1 style = "color:green;"> GeeksForGeeks </h1> <p> How to concat strings in AngularJS </p> <div ng-app = "app"> <div ng-controller = "controller"> str1 - '{{str1}}' <br> str2 - '{{str2}}' <br> <br> <input type = "button" ng-click = "join()" value = "Click Here"> <br> <p>Result = '{{res}}'</p> </div> </div> </body> </html> Output: Comment More infoAdvertise with us Next Article How to concat strings using AngularJS ? P PranchalKatiyar Follow Improve Article Tags : Web Technologies HTML AngularJS HTML-Misc AngularJS-Misc +1 More Similar Reads How to convert string into a number using AngularJS ? In this article, we will see how to convert a string into a number in AngularJS, along with understanding its implementation through the illustrations. Approach: The parseInt() method is used for converting the string to an integer. We will check whether the string is an integer or not by the isNumb 2 min read How to change the date format using AngularJS ? In this article, we will see how to change the date format using AngularJS. AngularJS provides 2 different ways to change the format of the date. It can be achieved by the following approaches: Using HTML Template BindingUsing JavaScript ControllerHTML Template Binding: In this method, we use the pi 3 min read How to encode/decode URL using AngularJS ? In this article, we will see the mechanism to encode/decode URL using AngularJS, along with knowing the different methods available to accomplish the given task, & will understand it through the illustration. A URL specifies a resource and its access protocol.Encode URL: URL Encoding is a way to 3 min read How to get form input value using AngularJS ? Given a form element and the task is to get the form values input by the user with the help of AngularJS.Approach: We are storing the data in the JSON object after the user enters it in the input element with the help of the Angular.copy(object) method. After that, data from the JSON object can be a 2 min read How to use $scope.$apply() in AngularJS ? In this article, we will be discussing the $apply() function & how to use it in angularjs. In AngularJS, $apply() function is used to evaluate expressions outside of the AngularJS context (browser DOM Events, XHR). Moreover, $apply has $digest under its hood, which is ultimately called whenever 3 min read How to push elements in an array using AngularJS ? Given an array and the task is to perform the push operation on the array using AngularJS. The arr.push() method is used to push one or more values into the array, & new values will add at the end of an array. This method changes the length of the array by the number of elements added to the arr 2 min read How to count array items in AngularJS ? Given an array and the task is to get the length of an array variable in AngularJS. For this, we will be using the .length() method to get the length of an array variable. Syntax: array.length();Example 1: In this example, the array length is shown by the alert box. Here, we have an array containing 2 min read How to print an array in table format using angularJS? Given an array & the task is to print the given array in the tabular format using AngularJS. In JavaScript, data can be stored in the form of arrays. Each of the array items has unique indexing, starting from 0. But what if the developer wants to display all the items that are in the array, on t 4 min read How to use filter within controllers in AngularJS ? In this article, we will see how to use the Filter inside the controller using AngularJS. Filters are used to format the value of an expression and display it to the user. It can be used in HTML Previews, Controllers or Services, and directives. AngularJS facilitates many built-in filters, although, 4 min read How to use comma as list separator in AngularJS ? In this article, we will use commas as a list separator in AngularJS applications.In AngularJS, we can use a list separator by simply placing the command between the items in the list. If we have an array of items that we need to display in the application, then we can use ng-repeat to iterate throu 4 min read Like