Javascript 在angularJs中创建指令
我正在尝试用angularJS创建一个指令。但它不起作用。我所做的如下 我的主要html代码Javascript 在angularJs中创建指令,javascript,html,angularjs,Javascript,Html,Angularjs,我正在尝试用angularJS创建一个指令。但它不起作用。我所做的如下 我的主要html代码 <body ng-app="birthdayToDo" ng-controller="main"> <h1>Hello Plunker!</h1> <myCustomer></myCustomer> </body> mydirectiveFile.html代码 <table> <tr>
<body ng-app="birthdayToDo" ng-controller="main">
<h1>Hello Plunker!</h1>
<myCustomer></myCustomer>
</body>
mydirectiveFile.html代码
<table>
<tr>
<td>SNo.</td>
<td>Name</td>
<td>Email</td>
</tr>
<tr ng-repeat="employee in employees">
<td>{{$index+1}}</td>
<td>{{employee.Name}}</td>
<td>{{employee.Email}}</td>
</tr>
</table>
斯诺。
名称
电子邮件
{{$index+1}}
{{employee.Name}
{{employee.Email}
但是这个代码不起作用。我在做什么
您有两种命名选项: 1.
app.directive('myCustomer', function()
<my-customer> </my-customer>
app.directive('mycustomer', function()
<mycustomer> </mycustomer>
app.directive('myCustomer',function()
2.
app.directive('myCustomer', function()
<my-customer> </my-customer>
app.directive('mycustomer', function()
<mycustomer> </mycustomer>
app.directive('mycustomer',function()
您有两个命名选项:
1.
app.directive('myCustomer', function()
<my-customer> </my-customer>
app.directive('mycustomer', function()
<mycustomer> </mycustomer>
app.directive('myCustomer',function()
2.
app.directive('myCustomer', function()
<my-customer> </my-customer>
app.directive('mycustomer', function()
<mycustomer> </mycustomer>
app.directive('mycustomer',function()
更改
<myCustomer></myCustomer>
为此:
<my-customer></my-customer>
更改
<myCustomer></myCustomer>
为此:
<my-customer></my-customer>
指令使用snake-case 将您的HTML更改为
<my-customer></my-customer>
始终记住ng app、ng click等指令使用snake-case 将您的HTML更改为
<my-customer></my-customer>
始终记住ng应用程序、ng单击等