Note that there are some explanatory texts on larger screens.

plurals
  1. POngController method called twice
    primarykey
    data
    text
    <p>I've got an angularjs app with a nav bar inside my index.html page like that : </p> <pre><code>&lt;div class="navbar navbar-inverse navbar-fixed-top" ng-controller="NavCtrl"&gt; &lt;div class="navbar-inner"&gt; &lt;div class="container"&gt; &lt;ul class="nav"&gt; &lt;li&gt; &lt;a href="#/"&gt;Home&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#/add"&gt;Add a contact&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#/users"&gt;Users&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#/agencies"&gt;Agencies&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a ng-click="intro()"&gt;Help&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This div use a controller, and when i click on the help link it calls the intro method of my controller. But this method is called twice each time !!</p> <p>This is my controller : </p> <pre><code>'use strict'; angular.module('myApp') .controller('NavCtrl', function ($scope, $location) { $scope.intro = function(){ if($location.path() != '/'){ toastr.warning("Warning."); }else{ introJs().start(); } } }); </code></pre> <p>Any idea ?..</p> <p>This is the complete html : </p> <pre><code> &lt;div class="navbar navbar-inverse navbar-fixed-top" ng-controller="NavCtrl"&gt; &lt;div class="navbar-inner"&gt; &lt;div class="container"&gt; &lt;ul class="nav"&gt; &lt;li ng-class="navClass('')"&gt; &lt;a href="#/"&gt;Home&lt;/a&gt; &lt;/li&gt; &lt;li ng-class="navClass('add')"&gt; &lt;a href="#/add"&gt;Add a contact&lt;/a&gt; &lt;/li&gt; &lt;li ng-class="navClass('users')"&gt; &lt;a href="#/users"&gt;Users&lt;/a&gt; &lt;/li&gt; &lt;li ng-class="navClass('agencies')"&gt; &lt;a href="#/agencies"&gt;Agencies&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a ng-click="intro()"&gt;Help&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="show-grid"&gt;&lt;/div&gt; &lt;div class="container"&gt; &lt;div class="row" ng-view&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload