Este artigo descreve o método do AngularJS usando diretrizes personalizadas da diretiva para implementar a herança do atributo. Compartilhe -o para sua referência, como segue:
1. Código HTML:
<! Doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <> src = "../../ content/plugins/angular/angular.minmin.js"> </script> </ad Head> <corpo ng-app = "mainApp" ng-controller = "mainController"> <quber-grid style = "borda: 1px sólido #fm;
2. Arquivo tmp.html
<Div Quber-Grid-Attr> Eu sou o conteúdo do modelo para o teste! </div>
3. Código JS:
// Inicialize o objeto angular var myng = angular.module ('mainApp', []); myng.directive ('qubergrid', function () {return {restrito: 'ea', substitua: true // remover o <quber-grid> tag Evento denominado sendChildGridattr sco. $ transmite ('sendChildGridattr', att); (Val, chave, obj) {if (key! = '$ att' && key! }}; }}; }); myng.Controller ('MainController', função ($ scope) {});Os efeitos são os seguintes:
Espero que este artigo seja útil para a programação do AngularJS de todos.