angular.js - directive命名规则?

浏览:31日期:2023-02-04

问题描述

directive只能由小写字母组成吗?

.directive(’名称’, function() { return {restrict: ’AE’,template: ’<p>Hi there</p>’,replace: true };});

例如,hello okhelloAnot workHello not workhello_a not workhello-a not work

我的要一个词组命名怎么办?

问题解答

回答1:

采用驼峰式命名如:hello A not work命名为:helloANotWork

详细规则:在html中使用如下方式

html<my-new-directive></my-new-directive>

但是定义指令时需要这样

javascriptmyApp.directive('myNewDirective', function(){...});

相关文章: