简体   繁体   English

我可以包含没有自定义标签或选择器的 angular 1 个组件吗

[英]Can i include angular 1 component without custom tag or selector

Hi I have angular 1 component:嗨,我有 angular 1 个组件:

angular.module('main').directive('globalNotification', (_, moment, $modal, Auth, Payments, adds) => ({
  restrict: 'E',
  replace: true,
  templateUrl: '/client/directive/global-global-notification/global-notification.html',

And previously it was rendered in index as <global-notification></global-notification> But now i have angular 1 and vue js working together and Vue complaining about that custom component because it is not related to vue.以前它在索引中呈现为<global-notification></global-notification>但现在我有 angular 1 和 vue js 一起工作,Vue 抱怨那个自定义组件,因为它与 vue 无关。

So, question can i somehow render component like this <div global-notification></div> to remove error from console.所以,问题我可以以某种方式呈现像这样的组件<div global-notification></div>以从控制台中删除错误。 Is there are any pitfalls in this approach?这种方法有什么陷阱吗?

I believe, that in your case, you can just change restriction from E to A .我相信,在您的情况下,您可以将限制从E更改为A

restrict: 'A',
<div global-notification></div>

As documentation ( https://docs.angularjs.org/guide/directive ) says:作为文档( https://docs.angularjs.org/guide/directive )说:

'A' - only matches attribute name
'E' - only matches element name
'C' - only matches class name
'M' - only matches comment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除angular2组件的选择器标签 - Remove the angular2 component's selector tag 如何动态设置angular2组件标签的样式? - How can i style an angular2 component tag dynamically? 我可以在自定义角度元素的html标签中传递args吗? - Can I pass args in the html tag of my custom angular element? 我可以制作一个Angular指令来匹配CSS选择器(而不仅仅是标签名称)吗? - Can I make an Angular directive to match a CSS selector (not just tag name)? 我们可以用 angular 中的自定义 css 覆盖选择器的默认 styles - can we override the default styles of selector with custom css in angular 我无法将Angular Datepicker包含到模块中 - I Can't include Angular Datepicker to module 在角度中,如何仅在没有尾随标记的情况下将ng-if用于包含标签 - In angular, how can I use ng-if for the containing tag only without the trailing markup jQuery选择器不适用于Angular ng-include - JQuery selector not working on Angular ng-include 如何在不将其模拟到打字稿测试中的情况下注入自定义角度服务? - How can I inject a custom angular service without mocking it into a test in typescript? 如何在不对ID进行硬编码的情况下获取有角度的自定义指令的焦点? - How can I grab focus of an angular custom directive without hardcoding an ID?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM