我试图根据我的学习制作一个项目,我想在这个网站上使用AngularJS,但我有导航问题。单击导航时,表单无法显示。
这是导航
的代码<nav>
<ul id="main_menu">
<li><a class="active" ng-model="myVar" value="Home" title="Home">Home</a></li>
<li><a ng-model="myVar" value="Employees" title="New Employee">Register new Employee</a></li>
<li><a ng-model="myVar" value="Customers" title="New Customer">Register new Customer</a></li>
<li><a ng-model="myVar" value="Members" title="New Member">Register new Member</a></li>
</ul>
</nav>
这就是我点击导航按钮时想要显示的表格
<div ng-switch="myVar">
<div ng-switch-when="Home">
<h2>Welcome to Gate's Corporate Portal </h2>
<p class="pindex animated rotateIn">
With this online application:<br>
Your can add New Employees,
New Customers,
and New Members
</p>
<div ng-switch-when="Employees">
<div class="animated fadeInDown">
<form method="post" >
<legend>Register new Employee</legend>
<form method="post" action="employeesaction.php" >
<label for="name">Name:</label><input type="text" name="name"><br><br>
<label for="surname">Surname:</label><input type="text" name="surname"><br><br>
<label for="date_of_birth">Date of Birth:</label><input type="date" name="date_of_birth"><br><br>
<label for="telephone">Telephone:</label><input type="text" name="telephone"><br><br>
<label for="mobile">Mobile:</label><input type="text" name="mobile"><br><br>
<label for="email">Email:</label><input type="text" name="email"><br><br>
<label for="address">Address:</label><input type="text" name="address"><br><br>
<label for="tin">Tin:</label><input type="text" name="tin"><br><br>
<label for="employee_id">Employee id:</label><input type="text" name="employee_id"><br><br>
<p class="center">
<button class="button1 animated flipInX" type="submit" value="Submit">Register</button> <button class="button2 animated flipInY" type="reset" value="reset">Clear form</button>
</form>
</div>
</div>
<div ng-switch-when="Customers">
<legend>Register new Customer</legend>
<form method="post" action="customersaction.php">
<label for="name">Name:</label><input type="text" name="name"><br><br>
<label for="surname">Surname:</label><input type="text" name="surname"><br><br>
<label for="telephone">Telephone:</label><input type="text" name="telephone"><br><br>
<label for="mobile">Mobile:</label><input type="text" name="mobile"><br><br>
<label for="customers_company">Customers company:</label><input type="text" name="customers_company"><br><br>
<label for="email">Email:</label><input type="text" name="email"><br><br>
<label for="address">Address:</label><input type="text" name="address"><br><br>
<label for="tin">Tin:</label><input type="text" name="tin"><br><br>
<p class="center">
<button class="button1 animated flipInX" type="submit" value="Submit">Register</button> <button class="button2 animated flipInY" type="reset" value="reset">Clear form</button></p>
</div>
<div ng-switch-when="Members">
<div class="animated fadeInDown">
<legend >Register new Member</legend>
<form method="post" action="membersaction.php">
<label for="name">Name:</label><input type="text" name="name"><br><br>
<label for="surname">Surname:</label><input type="text" name="surname"><br><br>
<label for="telephone">Telephone:</label><input type="text" name="telephone"><br><br>
<label for="mobile">Mobile:</label><input type="text" name="mobile"><br><br>
<label for="email">Email:</label><input type="text" name="email"><br><br>
<p class="center">
<button class="button1 animated flipInX" type="submit" value="Submit">Register</button> <button class="button2 animated flipInY" type="reset" value="reset">Clear form</button></p>
</form>
<br><br><br><br><br><br><br><br><br><br>
</div>
</div>
</div>
答案 0 :(得分:0)
在<nav>
中,您似乎正在尝试使用可以使用单选按钮的方法,但这不适用于<a>
元素。使用<a>
来实现此目的的方法如下所示:
<nav>
<ul id="main_menu">
<li><a ng-click="updateMyVar('Home')" class="active" title="Home">Home</a></li>
<li><a ng-click="updateMyVar('Employees')" title="New Employee">Register new Employee</a></li>
<li><a ng-click="updateMyVar('Customers')" title="New Customer">Register new Customer</a></li>
<li><a ng-click="updateMyVar('Members')" title="New Member">Register new Member</a></li>
</ul>
</nav>
然后在你的控制器中,你可以像myVar
那样为$scope.myVar = 'Home';
指定一个起始值:$scope.updateMyVar = function(value) {
$scope.myVar = value;
};
然后你需要创建一个简单的函数:
#include<sys/time.h>
long long timeInMilliseconds(void) {
struct timeval tv;
gettimeofday(&tv,NULL);
return (((long long)tv.tv_sec)*1000)+(tv.tv_usec/1000);
}