javascript - `ng-class` not working on functional call from included template -


i have main template called home.html, controller homecontroller applied throw : $routeprovider :

$routeprovider     .when ("/", {         templateurl : "views/home.html",         controller  : "homecontroller" });  $routeprovider     .otherwise ({         redirectto:'/' }); 

works fine. have seperate html template header' included in thehome.html` this:

<div class="content">     <ng-include src="'/views/header.html'"></ng-include>     <div class="globe">         <div class="progname">             <div class="swiper"></div>             <h2 class="active">                 <span class="title">                     {{activeapp.name}}                 </span>                 <span class="note">{{activeapp.note}}</span>             </h2>             <h2 class="que t{{$index+1}}" ng-click="activate(app)" ng-repeat="app in queapp">{{app.name}}</h2>          </div> 

for header have seperate controller called 'header.jswhich included in theindex.html` file.

<script src="app.js"></script>     <script src="js/script/factory/server.js"></script>     <script src="js/script/controllers/header.js"></script>     <script src="js/script/controllers/homecontroller.js"></script>     <script src="js/script/directives/home/programnames.js"></script> 

in header, there class, want apply conditionally, added condition in header.html file (which included)

in header.js (headercontroller) trying add conditonal class, not working:

my header.js:

angular.module("tcpapp")     .controller('header', ['$scope', function ($scope) {          $scope.show = false;          $scope.menuhandler = function () {             $scope.show = !$scope.show;             console.log("i called");         }      }]); 

what missing here? way adding controller wrong? or need write function withing parent controller homecontroller itself?

can't keep seperate controller header , include other template?

andy 1 me handle? in advance.

update header html :

<header ng-controller="header" >     <h1><a href="#">tcp</a></h1>     <nav>         <a class="menu" ng-click="menuhandler()" href="#">menu</a>         <span ng-class="{'activate':show}">             <a href="#"><span>all</span></a>             <a href="#"><span>important</span></a>             <a href="#"><span>design</span></a>             <a href="#"><span>supply</span></a>             <a href="#"><span>contruction</span></a>             <a href="#"><span>issue log</span></a>         </span>     </nav> </header> 

try in home.html :

<div class="content">     <ng-include src="views/header.html"></ng-include>     //code here </div> 

remove '/' @ starting of path of header.html template.

this should trick, guess.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -