2

On clicking the click button the text in ng-model=name should get reflected in the <h2> tag.

<div ng-model="name">This is a text</div> 
<button ng-click="getname()">Click</button>
<h2>{{name}}</h2>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
K. Kashyap
  • 23
  • 3

1 Answers1

0

Try this:

<div ng-controller="dummy">
   <div ng-bind="name"></div> 
   <button ng-click="nameCopied=name">Click</button>
   <h2 ng-show="nameCopied" ng-bind="nameCopied"></h2>
<div>

with this controller code:

app.controller('dummy', function($scope) {
  $scope.name = "The text in first div";
  $scope.nameCopied = '';
});

See this Plunkr for reference: http://plnkr.co/edit/5qwwe05CD3JTEbjAYi3m?p=info

Alex Pollan
  • 863
  • 5
  • 13