Ionic CSS classes assignment

后端 未结 2 646
长情又很酷
长情又很酷 2021-01-28 20:02

I’m styling my app. Familiar with the basic theming components, SASS etc... But one thing that stands out and it not making sense is why when I preview the source in a running a

2条回答
  •  一向
    一向 (楼主)
    2021-01-28 20:42

    ion-header is an angular directive (as is ion-toolbar). Directives can have an associated HTML template and javascript. The extra classes are added by the javascript that belongs to each directive. The code below demonstrates an angular directive where a class is added to the original element. If you inspect the results you can also see an extra div being added - that is the result of the directive's template being added to the DOM.

    (function() {
      var app = angular.module("soDemo", []);
      app.directive("soDirective", SoDirective);
    
      function SoDirective() {
        var directive = {
          restrict: 'E',
          scope: {},
          link: link,
          template: '
    My directive contents
    ' }; return directive; /////////////////// function link(scope, element) { element.addClass('sample-class'); console.log(element.html()); } } })();
    .sample-class {
      display: block;
      border: 1px solid red;
    }
    
    .content {
      font-style: italic;
    }
    
    
    
    

提交回复
热议问题