2016-08-17 57 views
0

任何人都可以幫助我。 在index.html中,我運行ng-view,該代碼對應於Routing.js文件。該菜單調用兩個頁面main.html和product.htm。 main.htm,包含另一個名爲filterApp.html的頁面。 我需要隱藏一個嵌入main.html filterApp.html的頁面元素。我沒有成功。 如果我將include包含並直接將代碼放入main.html作品中。我讀過那個ng-ng-hide,並且包含不正常的工作。有什麼我可以做的。我需要將它放在單獨的文件中。 這是頁面的代碼。 謝謝你這麼多Angularjs ng-hide不能與ng-include模板一起使用

的Index.html

<html ng-app="appDataBoard"> 
<body ng-controller="mainController" > 
<ul > 
      <li class="nav-item start open"> 
       <a href="#/main" class="nav-link nav-toggle"></a> 
      </li> 
       <li class="nav-item "> 
          <a href="#/product" class="nav-link nav-toggle"> </a> 
       </li> 
     </ul> 

<div class="col-md-12 column sortable"> 
          <div ng-view></div> 
       </div> 
</body> 
</html> 

main.html中

<div class="jumbotron text-center"> 
    <h1>main Page</h1> 

    <p>{{ message }}</p> 
</div> 

<!-- INCLUDE FILTER APPS--> 
     <div ng-include="'./template/filterApp.html'" ></div> 

Product.html

<div class="jumbotron text-center"> 
    <h1>Product Page</h1> 

    <p>{{ message }}</p> 
p ng-hide="hide1">este parrafo se debe borrar</p> 
</div> 

filterApp.html

<div ng-hide="hselect1" > 
      <select id="select-1" multiple="multiple" onchange="RecargaSelectBU()" > 
      </select> 
     </div> 

Routing.js

// create the module and name it dbApp 
    var dbApp = angular.module('appDataBoard', ['ngRoute']); 

    // configure our routes 
    dbApp.config(function($routeProvider) { 
     $routeProvider 

      // route for the home page 
      .when('/main', { 
       templateUrl : 'template/main.html', 
       controller : 'mainController' 
      }) 

      // route for the about page 
      .when('/product', { 
       templateUrl : 'template/product.html', 
       controller : 'productController' 
      }) 

    }); 

    // create the controller and inject Angular's $scope 
    dbApp.controller('mainController', function($scope) { 
     // create a message to display in our view 
     $scope.message = 'Pagina principal'; 
     $scope.hselect1 = true; 
    }); 

    dbApp.controller('productController', function($scope) { 
     $scope.message = 'Pagina de producto.'; 
     $scope.hide1 = true; 

    }); 
+0

您需要爲此提供服務或允許它們共享相同的控制器。你可以把你的代碼放在plunkr上嗎? –

回答

0

入住此plunker鏈接。它爲我工作很好。 https://embed.plnkr.co/RZDGdnFEq1SmT7F3ncZa/

+0

艾哈邁德正確運作。這是我的經驗不足。非常感謝你的幫助 。問候 –

+0

@CesarBugari歡迎我的榮幸 –

相關問題