使用固定的导航栏导航到Angular 2+中的页面

时间:2019-03-20 05:57:42

标签: angular

我有一个选项列表,我想在其中导航到每个列表选项的每个页面。我可以知道怎么做吗?我只是尝试了路由器选项而所有的方法都不起作用。导航栏和页脚已设置在固定位置,背景区域中的内容应根据导航栏中的菜单选择进行更改。

1 个答案:

答案 0 :(得分:2)

您应该使用function update(){ if($this->input->post('submit')){ $id_user = $this->input->post('id'); $username = $this->input->post('username'); $cek = $this->db->query("SELECT id_user, username, password, nama FROM user WHERE role = 'users' AND id_user = '$id_user'"); $cek2 = $this->db->query("SELECT username FROM user WHERE role = 'users' AND id_user = '$id_user' AND username='$username'"); if($cek2->num_rows() == 1){ echo '<script type="text/javascript">'; echo 'alert("Username is invalid.");'; echo 'window.location.href = "'.$_SERVER['HTTP_REFERER'].'";'; echo '</script>'; }elseif($cek->num_rows() == 1){ $nama = $this->input->post('nama'); $new_password = md5($this->input->post('new_password')); $conf_password = md5($this->input->post('conf_password')); $status = $this->input->post('status'); if(strlen($new_password) > 0){ if($new_password != $conf_password){ echo '<script type="text/javascript">'; echo 'alert("Failed to update, new password is invalid!");'; echo 'window.location.href = "'.$_SERVER['HTTP_REFERER'].'";'; echo '</script>'; }else{ $data_update = array( 'nama' => $nama, 'username' => $username, 'password' => $new_password, 'status' => $status ); $this->db->where('id_user',$id_user); $this->db->update('user',$data_update); $this->session->set_flashdata('item', array('message' => 'Success!','color' => 'info')); redirect('user'); } }else{ $data_update = array( 'nama' => $nama, 'username' => $username, 'status' => $status ); $this->db->where('id_user',$id_user); $this->db->update('user',$data_update); $this->session->set_flashdata('item', array('message' => 'Berhasil mengubah data!','color' => 'info')); } }else{ echo '<script type="text/javascript">'; echo 'alert("Failed to save!");'; echo 'window.location.href = "'.$_SERVER['HTTP_REFERER'].'";'; echo '</script>'; } }else{ echo '<script type="text/javascript">'; echo 'alert("Failed to save!");'; echo 'window.location.href = "'.$_SERVER['HTTP_REFERER'].'";'; echo '</script>'; } } 而不是通用路由方法。让我给一个示例代码

.html

navigateByUrl

.ts

<ul class="dropdown-menu">
 <li (click)="goToPage('account')">My Account</li>
</ul>

希望这对您有帮助