JavaScript $modal is not working as expected

var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('myCtrl', function($scope,$modal){
    $scope.firstName = "John";
    $scope.lastName = function(){
            $modal.open({
            template: '<h1>{{firstName}}</h1>',
            size: 'sm',
            backdrop: 'static'
        })}
});
<link rel="stylesheet" target='_blank' href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script><div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="submit" ng-click="lastName()"><br>
<br>
Full Name: {{firstName}}

</div>
Answer:1

You can pass the $scope to the modal instance like this:

var app = angular.module('myApp', ['ui.bootstrap']);
app.controller('myCtrl', function($scope,$modal){
    $scope.firstName = "John";
    $scope.lastName = function(){
            $modal.open({
            scope: $scope,
            template: '<h1>{{firstName}}</h1>',
            size: 'sm',
            backdrop: 'static'
        })}
});
<link rel="stylesheet" target='_blank' href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script><div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="submit" ng-click="lastName()"><br>
<br>
Full Name: {{firstName}}

</div>
Answer:2

I'm just starting out with Angular. I've written some code that downloads a JSON array configuredAPIs and displays each object within it, <div ng-repeat="capi in configuredAPIs">. For each of ...

I'm just starting out with Angular. I've written some code that downloads a JSON array configuredAPIs and displays each object within it, <div ng-repeat="capi in configuredAPIs">. For each of ...

  1. angular cheilitis
  2. angular velocity
  3. angular momentum
  4. angular acceleration
  5. angular speed
  6. angular material
  7. angular velocity formula
  8. angular js
  9. angular speed formula
  10. angular cli
  11. angular acceleration formula
  12. angular 9
  13. angular frequency
  14. angular momentum formula
  15. angular gyrus
  16. angular vs react
  17. angular tutorial
  18. angular interview questions
  19. angular momentum equation
  20. angular 8

I've never used scrollspy in my project and I need to know how it works. I have seen the documentation from the bootstrap page, some other stackoverflow questions and youtube videos. I have this code:...

I've never used scrollspy in my project and I need to know how it works. I have seen the documentation from the bootstrap page, some other stackoverflow questions and youtube videos. I have this code:...

  1. bootstrap scrollspy not working
  2. bootstrap scrollspy not working correctly
  3. bootstrap scrollspy not working in chrome
  4. bootstrap scrollspy not working in react
  5. bootstrap scrollspy active not working
  6. bootstrap scrollspy offset not working
  7. bootstrap 4 scrollspy not working
  8. bootstrap scrollspy data-offset not working
  9. bootstrap 3 scrollspy not working
  10. bootstrap scrollspy smooth scroll not working

I want to get the tags name when I click on them, I have applied a common class on each tag. Now the proplem is when ever I click on p tag or h1 it always gives the parent name. $(function(){ $...

I want to get the tags name when I click on them, I have applied a common class on each tag. Now the proplem is when ever I click on p tag or h1 it always gives the parent name. $(function(){ $...

I am trying to figure out how to use propeller.js to restrict the rotation angle of an image. As of right now, if I spin my image twice, my output would read 720. I would like to make it so the ...

I am trying to figure out how to use propeller.js to restrict the rotation angle of an image. As of right now, if I spin my image twice, my output would read 720. I would like to make it so the ...