Controller.js:
.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>
我是棱角分明的新人,这是我的问题: 我的controller.js链接到我的parametres.html 我有以下错误:TypeError:无法读取属性'style'的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>
因为我想要做的是:当我在parametres.html中更改某些内容时,使用ng-change,我的按钮“edit”出现。 有人知道如何从控制器访问我的按钮“编辑”的css属性,而不是离子内容吗?
答案 0 :(得分:0)
好吧,我只想用它:
<button ng-style="displayed" class="button button-clear button-positive">Edit</button>
并在我的控制器中:$scope.displayed = {'color':'red'};
我不知道ng-class存在!
它有效!