2016-03-08 90 views
-1

Controller.js:Sidemenu訪問離子

.controller('ParametresCtrl',['$scope','$stateParams','$state','cgtdata','$ionicPopup', 

function($scope,$stateParams,$state,cgtdata,$ionicPopup) { 
    document.getElementById('test').style.color='red'; 

menu.html:

<ion-side-menus enable-menu-with-back-views="true"> 
    <ion-side-menu-content> 
    <ion-nav-bar class="bar-stable"> 


     <ion-nav-buttons side="left"> 
     <button class="button button-icon button-clear ion-navicon" menu-toggle="left"> 
     </button> 
     </ion-nav-buttons> 
    </ion-nav-bar> 
    <ion-nav-view name="menuContent"></ion-nav-view> 
    </ion-side-menu-content> 

    <ion-side-menu side="left"> 
    <ion-header-bar class="bar-stable"> 
     <h1 class="title">Tiime-ae</h1> 
    </ion-header-bar> 
    <ion-content> 
     <ion-list> 
     <!--<ion-item menu-close ng-click="login()"> 
      Login 
     </ion-item>--> 
     <ion-item menu-close href="#/app/home"> 
      Home 
     </ion-item> 
     <ion-item menu-close href="#/app/registre"> 
      registre 
     </ion-item> 
     <ion-item menu-close href="#/app/documents"> 
      Documents 
     </ion-item> 
     <ion-item menu-close href="#/app/facturer"> 
      Facturer 
     </ion-item> 
     <ion-item menu-close href="#/app/parametres"> 
      Paramètres 
     </ion-item> 
     </ion-list> 
    </ion-content> 
    </ion-side-menu> 
</ion-side-menus> 

parametres.html:

<ion-view view-title="Parametres"> 
    <ion-nav-buttons side="right"> 
    <div class="h1 title">Header Buttons</div> 
    <button id="test" class="button button-clear button-positive">Edit</button> 
    </ion-nav-buttons> 
    <ion-content> 

    <h2>Mon Compte</h2> 
    <ul class="list"> 
     <li class="item"> 
     <p class="param-right">{{email}}</p><p>Email :</p> 
     </li> 
     <li class="item" ng-click="changepass()"> 


     <div class="chevron-mdp ion-chevron-right" data-pack="default" data-tags="arrow,right"></div> 
     <p>Modifier mon mot de passe : </p> 
     </li> 
    </ul> 
    <h2>Activité</h2> 
    <ul class="list"> 
     <li class="item"> 
      <ion-toggle ng-repeat="item in settingsList" 
         ng-model="item.checked" 
         ng-checked="item.checked"> 
       {{ item.text }} 
      </ion-toggle> 

     </li> 
    </ul> 
    <h2 id="edit">Mon entreprise</h2> 
    <ul class="list"> 
     <div class="list"> 
      <label class="item item-input item-select"> 
      <div class="input-label"> 
       Période de déclaration 
      </div> 
      <select> 
       <option>Mensuelle</option> 
       <option>Trimestrielle</option> 
      </select> 
      </label> 
     </div> 


     <div class="list"> 
      <label class="item item-input item-select"> 
      <div class="input-label"> 
       Bénéficiaire ACCRE 
      </div> 
      <select> 
       <option>Oui</option> 
       <option>Non</option> 
      </select> 
      </label> 
     </div> 




     <li class="item"> 
      <input ng-change="firstchange()" ng-model="nam" class="param-right"></input><p>Prénom</p> 
     </li> 
     <li class="item"> 
      <p class="param-right">{{lastname}}</p><p>Nom</p> 
     </li> 
     <li class="item"> 
      <p class="param-right">{{commercial}}</p><p>Nom Commercial</p> 
     </li> 
     <li class="item"> 
      <p class="param-right">{{siret}}</p><p>Siret</p> 

     </li> 
     <li class="item"> 
      <p class="param-right">{{creation}}</p><p>Date de création</p> 

     </li> 
     <li class="item"> 
      <p class="param-right">{{addresse}}</p><p>Addresse</p> 

     </li> 
     <li class="item"> 
      <p class="param-right">{{cp}}</p><p>Code postal</p> 

     </li> 
     <li class="item"> 
      <p class="param-right">{{city}}</p><p>Ville</p> 
     </li> 
     <li class="item"> 
     <p class="param-right">{{country}}</p><p>Pays</p> 
     </li> 
     <li class="item"> 
     <p class="param-right">{{phone}}</p><p>Téléphone</p> 
     </li> 
     <li class="item"> 
      <p>Ville d'imatriculation au RCS :</p> 
     </li> 
    </ul> 
    <h2>Factures</h2> 
     <div class="list"> 
      <label class="item item-input item-select"> 
      <div class="input-label"> 
       Délai de réglement 
      </div> 
      <select> 
       <option>A la réception</option> 
       <option>une semaine</option> 
       <option>15 jours</option> 
       <option>3 semaines</option> 
       <option>30 jours</option> 
       <option>40 jours</option> 
       <option>45 jours</option> 
       <option>60 jours</option> 
      </select> 
      </label> 
     </div> 

     <li class="item" ng-click="entete()"> 
      <div class="chevron-mdp ion-chevron-right" data-pack="default" data-tags="arrow,right"></div> 
     <p>En tête</p> 
     </li> 
     <li class="item" ng-click="mentions()"> 
      <div class="chevron-mdp ion-chevron-right" data-pack="default" data-tags="arrow,right"></div> 
      <p>Mentions légales</p> 

     </li> 
     <li class="item" ng-click="piedpage()"> 
      <div class="chevron-mdp ion-chevron-right" data-pack="default" data-tags="arrow,right"></div> 
     <p>Pied de page</p> 


     </li> 
    </ul> 
    <div class="button-bar bar-assertive"> 
     <a class="button activated" ng-click="showConfirm()">Deconnexion</a> 
    </div> 



    </ion-content> 
</ion-view> 

我M在新的角度,這裏是我的問題: 我的controller.js鏈接到我的parametres.html ,我有以下錯誤:TypeError:Can not讀屬性'風格'null

因爲我想在我的控制器上使用我的按鈕「編輯」的css。所以我把我的按鈕放入parametres.html。

<ion-view view-title="Parametres"> 
    <ion-nav-buttons side="right"> 
    <div class="h1 title">Header Buttons</div> 
    <button id="test" class="button button-clear button-positive">Edit</button> 
    </ion-nav-buttons> 
    <ion-content> 

因爲我希望做的是:與NG-變化,當我改變parametres.html類似的值,我的按鈕「編輯」出現。 有人知道我怎麼可以訪問我的按鈕「編輯」從控制器不在離子內容的css屬性?

回答

0

好,我只是用這個:

<button ng-style="displayed" class="button button-clear button-positive">Edit</button> 

,並在我的控制器:$scope.displayed = {'color':'red'};

我不知道這存在納克級!

它的工作原理!