0

I've got an angularjs app with a nav bar inside my index.html page like that :

<div class="navbar navbar-inverse navbar-fixed-top" ng-controller="NavCtrl">
        <div class="navbar-inner">
            <div class="container">
                <ul class="nav">
                    <li>
                        <a href="#/">Home</a>
                    </li>
                    <li>
                        <a href="#/add">Add a contact</a>
                    </li>
                    <li>
                        <a href="#/users">Users</a>
                    </li>
                    <li>
                        <a href="#/agencies">Agencies</a>
                    </li>
                    <li>
                        <a ng-click="intro()">Help</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>

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 !!

This is my controller :

'use strict';

angular.module('myApp')
    .controller('NavCtrl', function ($scope, $location) {

        $scope.intro = function(){
            if($location.path() != '/'){
                toastr.warning("Warning.");
            }else{
                introJs().start();
            }
        }

    });

Any idea ?..

This is the complete html :

    <div class="navbar navbar-inverse navbar-fixed-top" ng-controller="NavCtrl">
        <div class="navbar-inner">
            <div class="container">
                <ul class="nav">
                    <li ng-class="navClass('')">
                        <a href="#/">Home</a>
                    </li>
                    <li ng-class="navClass('add')">
                        <a href="#/add">Add a contact</a>
                    </li>
                    <li ng-class="navClass('users')">
                        <a href="#/users">Users</a>
                    </li>
                    <li ng-class="navClass('agencies')">
                        <a href="#/agencies">Agencies</a>
                    </li>
                    <li>
                        <a ng-click="intro()">Help</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>

    <div class="show-grid"></div>

   <div class="container">
        <div class="row" ng-view></div>
    </div>
Thomas Pons
  • 7,709
  • 3
  • 37
  • 55
  • 2
    Can you make a fiddle which reproduce the problem ? – Blackhole Jun 14 '13 at 14:39
  • I started noticing twice-called controller intro methods, too, when I introduced Angular's client-side routing. From your URLs it looks like you're using that too, so I wonder if it's related. Is the snippet you pasted anywhere within an ng-View directive? – blaster Jun 14 '13 at 15:05
  • I've edit the post i've got a ng-view directive for all the views with a $routeProvider .. the ng-controller directive is just used for the navbar ... – Thomas Pons Jun 14 '13 at 15:16
  • @Blackhole: for the fiddle i'll try but it's a little bit complicated , because i've got a $routeProvider many controllers and many partials views, but i'll try ! – Thomas Pons Jun 14 '13 at 15:22
  • In your fiddle, put just enough code to replicate this exact problem. We don't need your whole app. – Stewie Jun 14 '13 at 15:36
  • 1
    Based in your code I could not reproduce the problem, here is a [JSBin](http://jsbin.com/iwewub/19/edit) – Bertrand Jun 14 '13 at 15:53

1 Answers1

0

Resolved :

Someone (on my project) has added an angular.min script file ... We' have already the angular file for develoment ...

Two angular core library no conflict just methods called twice of course ...

Really my bad sorry guys thx for ur replies

Thomas Pons
  • 7,709
  • 3
  • 37
  • 55