title: bootstrap ui modal.open error:Cannot read property 'open' of undefined
body: <p>Im trying to make my first modal using Angularjs. I'm not sure or why I'm getting this error. I have error:</p>
  
  <pre><code>TypeError: Cannot read property 'open' of undefined
  </code></pre>
  
  <p>Here is my code:
  Layout:</p>
  
  <pre><code>&lt;html ng-app="app"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;title&gt;@ViewBag.Title&lt;/title&gt;
  
      &lt;script src="~/Scripts/angular.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/angular-resource.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/jquery-1.10.2.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/angular-route.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/ng-grid.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/bootstrap.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="~/Scripts/angular-ui/ui-bootstrap.js" type="text/javascript"&gt;&lt;/script&gt;
  
  
  
      &lt;script src="~/Scripts/app.js" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="~/Content/ng-grid.css" /&gt;
      &lt;link rel="stylesheet" type="text/css" href="~/Content/bootstrap.css" /&gt;
  
  
  &lt;/head&gt;
  &lt;body ng-controller="CtrlController"&gt;
              @RenderBody()                 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>(function() {
      var app = angular.module("app", ["ngGrid", "ui.bootstrap"]);
      app.controller("CtrlController", function ($scope, $http, $log, $modal) {
  
  
  
  
          $scope.on = function ($modal) {
              alert("dddd");
              $modal.open(
                  {
                      templateUrl: 'http://localhost:58652/Home/TestView',
                      controller: "CtrlController"
  
                  }
              );
          }
      });
  
  
  
  
  })()
  </code></pre>
  
  <p>HTML for button:</p>
  
  <pre><code>&lt;div ng-click="on()" class="gridStyle" ng-grid="gridOptions"&gt;
  &lt;/div&gt;
  &lt;button ng-click="on()" type=button class="btn"&gt;Добавить&lt;/button&gt;
  </code></pre>
  
  <p>But when I click the button, I get the error Cannot read property 'open' of undefined. Why is that? </p>