angularjs - Two search views accessing same controller -


i'm making hotel website , have search destination,arrive,depart etc on home page.

i have search integrated on different pages within site. used include template , have used ng-show hide on home page want use full page jumbotron search fields on home page.

therefore views different functionality same.

my home view looking home controller , search view looking search controller.

i have set global controller (i added functionality such page titles , active nav states css) me place both search forms can access , pass required data.

my global controller added body tag , can access onload console.log.

i thought access ng-submit="globalcontroller.setdestination()" on both forms nothing happens.

how can access global controller usng ng-submit? need these both go relative controllers route on somehow? there better way 2 views access/pass same data?

i know can make service have quite few $scope elements thought passing 2 views 1 controller might keep dry.

<form name="destinationsearch" ng-submit="globalcontroller.setdestination()"> 

part of template

<body ng-cloak ng-controller="globalcontroller">      <div id="wrap">           <header class="hidden-xs-up">             <h1 ng-bind="$state.current.data.pagetitle"></h1>         </header>          <!-- load header -->         <div ng-controller="navcontroller" ng-include src="'app/components/core/nav.html'"></div>         <!-- /header -->         <div>             <!-- load search -->             <div ng-show="globaldata.showsearchbar">                 <div ng-include src="'app/shared/search/searchview.html'"></div>             </div>               <!-- /search -->             <!-- angular -->             <div ui-view></div>             <!-- /angular -->         </div>     </div> 

try using controlleras syntax

<body ng-cloak ng-controller="globalcontroller gc"> 

then use

<form name="destinationsearch" ng-submit="gc.setdestination()"> 

check this more.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -