You have 'main_controller' declared (and thus instantiated twice, once in 
the html (via "ng-controller="main_controller"") and again n $routeProvider 
(via "controller : 'main_controller'").  Either remove the latter or rename 
it to another controller dedicated to the 'home.html' page/view.

On Friday, May 15, 2015 at 4:19:57 PM UTC-4, foysal foysal wrote:
>
> I new in AngularJS. I am learning AngularJS. I am trying to follow 
> different tutorials. I working with some codes now. I have a question in 
> this regard. My codes ares as below
>
> index.html
>
> <html>
>     <head>
>         <title>AngularJS Application</title>
>         <meta charset="UTF-8">
>         <meta name="viewport" content="width=device-width">   
>         <script 
> src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js";></script>
>         <script 
> src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
>         <script src="js/route.js"></script>
>     </head>
>     <body>
>         <div ng-app="main_app">
>             <div ng-controller="main_controller">
>                 <div ng-view></div>
>             </div>
>         </div>                
>     </body></html>
>
> route.js
>
> var app = angular.module('main_app',['ngRoute']);
>
> app.config(function($routeProvider){
>    $routeProvider
>
>    // route for the home page
>    .when('/', {
>                templateUrl : 'pages/home.html',
>                controller  : 'main_controller'
>             });});
>
> app.controller('main_controller', function($scope) {
>     alert('Yes');        });
>
> If I run this code I get the alert('Yes'); twice.
>
> Why I am getting this alert twice ?? Is it normal action or I am doing 
> something wrong ??
>
>
>
> Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to