从html创建一个指令,该指令按类名应用函数
Create a directives from html which apply function by class name
请告诉我如何从使用jQuery插件重写这些代码到与AngularJs一起使用的指令:
<div class="fotorama" data-nav="thumbs" data-allowfullscreen="1" data-thumbheight="100" data-thumbwidth="100">
<img src="img/gamer_chick_800x600.jpg" alt="Image Alternative text" title="Gamer Chick" />
<img src="img/amaze_800x600.jpg" alt="Image Alternative text" title="AMaze" />
<img src="img/urbex_esch_lux_with_laney_and_laaaaag_800x600.jpg" alt="Image Alternative text" title="Urbex Esch/Lux with Laney and Laaaaag" />
<img src="img/food_is_pride_800x600.jpg" alt="Image Alternative text" title="Food is Pride" />
</div>
当在AngularJS中运行应用程序时,此代码将被放在"视图"HTML文件中。谢谢
我为您的问题添加了plunkr。请参阅以下链接http://plnkr.co/edit/n571gvlq7ptlbfJbOgaT?p=preview
代码
Main html
<!DOCTYPE html>
<html ng-app="docsIsolationExample">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="example.js"></script>
</head>
<body>
<div ng-controller="Controller">
<my-customer ></my-customer>
</div>
</body>
</html>
代码将被放入html视图
<div class="fotorama" data-nav="thumbs" data-allowfullscreen="1" data-thumbheight="100" data-thumbwidth="100">
<img src="img/gamer_chick_800x600.jpg" alt="Image Alternative text" title="Gamer Chick" />
<img src="img/amaze_800x600.jpg" alt="Image Alternative text" title="AMaze" />
<img src="img/urbex_esch_lux_with_laney_and_laaaaag_800x600.jpg" alt="Image Alternative text" title="Urbex Esch/Lux with Laney and Laaaaag" />
<img src="img/food_is_pride_800x600.jpg" alt="Image Alternative text" title="Food is Pride" />
</div>
JS
angular.module('docsIsolationExample', [])
.controller('Controller', ['$scope', function($scope) {
$scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
$scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' };
}])
.directive('myCustomer', function() {
return {
restrict: 'E',
scope: {
customerInfo: '=info'
},
templateUrl: 'my-customer-plus-vojta.html'
};
});
您可以使用自定义指令将temple添加到html页面。请参阅以下链接了解如何实现自定义指令。
创建包装其他元素的指令
相关文章:
- 从html创建一个指令,该指令按类名应用函数
- AngularJS指令单元测试中未定义的函数
- AngularJS指令部分应用的函数don'不起作用
- 角度指令's链接函数未被调用
- 从子指令调用指令函数不起作用
- 参数未在指令函数中传递
- 如何从 JavaScript 调用指令函数
- Angular.js调用控制器中的指令函数
- 将事件发送到范围中的角度指令函数
- 从父指令角度调用指令函数
- 在具有不同控制器的视图中使用ng-click和指令函数
- 通过参数将 mongo 文档 ID 传递给角度指令函数会抛出解析错误
- Angular指令——函数执行的正确顺序
- 又一个没有传递参数的Angular指令函数
- 如何使子链接指令函数在父控制器之前运行
- AngularJS中指令函数的执行顺序
- 在没有应用指令函数的指令内部重复
- 使用$scope.$parent.$$childHead从控制器访问指令函数.AngularJS中的functionNa
- angularjs设计.从另一个控制器调用指令函数
- 调用angularjs指令函数的范围问题