In Angular JS how to display 2 ng-bind items on the same line?

1.1k views Asked by At

I have the following code :

  <div id="App2" ng-app="namesList" ng-controller="NamesController" ng-init="firstName='John';lastName='Doe'">
   First Name: <input type="text" ng-model="firstName"><br>
   Last Name: <input type="text" ng-model="lastName"><br>
   <br>
   Full Name: {{firstName + " " + lastName}}<Br>
   The name is : <p><span ng-bind="firstName" /span></p>
   <p><span ng-bind="lastName" /span></p>
  </div>

In the 1st case it shows up correctly, but the 2nd case breaks the names into 2 lines, if I remove the <P> and </P>, it won't show, so how to use ng-bind to display the names in one line ?

1

There are 1 answers

0
Tomek Sułkowski On BEST ANSWER

You need to fix those spans:

The name is : 
<p><span ng-bind="firstName"></span> <span ng-bind="lastName"></span></p>

(they were closed incorrectly)