这是我的代码示例.在我的情况下,切换类适用于每个li元素
<ul class="nav nav-pills pull-right">
<li *ngFor="let x of nav" class="presentation" (click)="active = !active" [ngClass]="toggleClass()">
<a href="#">{{x.menu}} </a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
JS
export class AppComponent {
active = false;
nav = NAVIGATION;
//Toggle Class
toggleClass(){
if(this.active){
return 'active';
} else {
return '';
}
}
Run Code Online (Sandbox Code Playgroud) 您好我需要使用angular2 *ngIf语句来切换类
<i *ngIf="visible" [(ngClass)]="{{arrow}}"></i> <<这行代码不能正常工作
这是我的ts代码
private visible = true;
private i = 0;
private arrow = 'ic-v';
private showList(){
if(this.i == 0){
this.i = 1;
this.visible = false;
this.arrow = 'ic-v-up';
}
else
{
this.i = 0;
this.visible = true;
this.arrow = 'ic-v';
}
}
Run Code Online (Sandbox Code Playgroud) 您好,我有这段代码:将鼠标悬停在a标签上时,过渡有效,但文本消失。我该如何解决这个问题?
<header>
<ul class="menu">
<li><a href="#">main</a></li>
<li><a href="#">about us</a></li>
<li><a href="#">brands</a></li>
<li><a href="#">gallery</a></li>
<li><a href="#">contact</a></li>
</ul>
</header>
<style type="text/css">
header ul li a {
text-decoration: none;
color: #333946;
font-size: 20px;
padding: 20px;
-webkit-transition: background-color 0.5s; /* For Safari 3.1 to 6.0 */
transition: background-color 0.5s;
}
a:hover {
background-color: #333946;
opacity: 0.5;
border-radius: 3px;
}
</style>
Run Code Online (Sandbox Code Playgroud) 我需要Name从数据库中选择Email = $email;
if ($result) {
$Name = $this->db->select('Name');
$this->db->from('users');
$this->db->where('Email',$Email);
$sess_array = array(
'Name' => $Name
);
$this->session->set_userdata('logged_in',$sess_array);
print_r($sess_array);
}
Run Code Online (Sandbox Code Playgroud) 嗨所有我需要的是,如果窗口少于768px警报一些,如果窗口超过768px警报一些,我有这个脚本,else if(){}当窗口大小超过768px
ps 时不工作我需要这个heppend总是当窗口小于768px或超过768px
var i = 0;
$(window).resize(function(){
if(width < 768 && i == 0){
alert('less than 768px');
i++;
alert(i);
}else if(width > 768){
alert('more than 768px');
i==0;
}
});
Run Code Online (Sandbox Code Playgroud) angular ×2
css ×2
jquery ×2
codeigniter ×1
css3 ×1
javascript ×1
mysql ×1
php ×1
typescript ×1