GVKun编程网logo

angular2:如何通过条件手动将css文件添加到index.html?

7

对于想了解angular2:如何通过条件手动将css文件添加到index.html?的读者,本文将是一篇不可错过的文章,并且为您提供关于android–手动将本地文件添加到下载应用程序、Android

对于想了解angular2:如何通过条件手动将css文件添加到index.html?的读者,本文将是一篇不可错过的文章,并且为您提供关于android – 手动将本地文件添加到下载应用程序、Android:如何手动将文件添加到apk?、Angular 10:如何创建动态Component / html?、Angular 2 Typescript编译器复制html和css文件的有价值信息。

本文目录一览:

angular2:如何通过条件手动将css文件添加到index.html?

angular2:如何通过条件手动将css文件添加到index.html?

下面的代码是为样式定义的.

总结

以上是小编为你收集整理的angular2:如何通过条件手动将css文件添加到index.html?全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

android – 手动将本地文件添加到下载应用程序

android – 手动将本地文件添加到下载应用程序

我的应用程序需要下载文件,我正在查看DownloadManager,但它有一些不适合我的情况(身份验证,命名方案,验证)的限制,所以我做了我的自定义下载引擎.

是否可以手动将使用我的引擎下载的文件(因此使用本地URL)添加到下载系统应用程序的列表中?我的理解是列表由系统内容提供者填充.是否可以在没有DownloadManager尝试下载文件的情况下向其中添加记录?

谢谢

总结

以上是小编为你收集整理的android – 手动将本地文件添加到下载应用程序全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

Android:如何手动将文件添加到apk?

Android:如何手动将文件添加到apk?

如何手动将文件添加到 Android APK包中?

解决方法

apk是一个拉链的罐子.所以你可以使用任何操纵拉链的工具.

但是还有一个复杂的问题:Android平台需要对apk中的所有文件(meta-inf目录中的文件除外)进行签名.所以你需要再次拨打jarsigner来签署所有包裹.然后你应该再次拨打zipalign.

您必须使用用于签署原始apk的相同密钥对已修改的apk进行签名.这是签名的全部要点:它表示未经签名者批准,包裹未被篡改. (实际上,您可以使用其他密钥进行签名,但之后您将无法访问原始应用程序生成的任何数据,反之亦然.)

随Android开发工具包提供的ant脚本包含运行jarsigner和zipalign的自动化.

Angular 10:如何创建动态Component / html?

Angular 10:如何创建动态Component / html?

  1. 问题:

您可以将字符串/ html变量绑定到[innerHTML]属性绑定。

<div [innerHTML]="theHtmlString"></div>

如果html不起作用,则需要注入DomSanitizer来告诉angular html是安全的。

 constructor(private sanitizer:DomSanitizer) {
    this.htmlString = this.sanitizer.bypassSecurityTrustHtml(style);
  }
  1. 问题:

您可以使用@ViewChild动态创建组件,并从div中获取ViewContainerRef并使用componentFactoryResolver:

模板:

<div #yourdiv></div>

组件:

@ViewChild("yourdiv",{read: ViewContainerRef}) private vcr: ViewContainerRef;
   
constructor(private componentFactoryResolver: ComponentFactoryResolver) {

    let resolver = this.componentFactoryResolver.resolveComponentFactory(DynamicComponent);
    let componentFactory =  this.vcr.createComponent(resolver);
  
  }

Angular 2 Typescript编译器复制html和css文件

Angular 2 Typescript编译器复制html和css文件

在Angular2我会有
"outDir": "dist/app"

在tsconfig.json.因此,在/ dist / app /文件夹和/或其子文件夹中生成了.iled和.map文件.这一切都很好.

在我的components.ts文件中,我也使用了这样引用的html和css

@Component({
  selector: 'my-app',templateUrl: 'app/appshell/app.component.html',styleUrls: ['app/appshell/app.component.css'],......
}

有没有办法使编译器也复制整个项目的引用的html和css文件?
如果是,我该如何配置我的tsconfig.json?

我查看了这里的编译器选项https://www.typescriptlang.org/docs/handbook/compiler-options.html,但没有找到有关复制html / css文件的任何内容.

更新:
我的文件夹结构是这样的

Root
  |--app       // for ts
  |--dist/app  // for js

tsconfig.json

"outDir": "dist/app"

的package.json

{
  "name": "TestApp","version": "1.0.0","scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ","html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;",......
}

它不复制html文件.没有错误.

再次更新:

对于那些在Linux操作系统上的人来说,Bernardo的解决方案是一个工作的解决方案.
对于那些在Windows操作系统上的人来说,以下应该是正常的.

"scripts": {
    "html": "XcopY /S /y .\\app\\*.html .\\dist\\app" }
不,TypeScript编译器只适用于* .ts文件.

您必须使用复制方法(例如cpm shell命令)复制其他文件,如* .html和* .css,例如npm脚本或grunt-contrib-copy.

使用npm脚本的示例:

"scripts": {
  "html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;"
}

只需运行npm在shell中运行html.

使用grunt的例子:

copy: {
      html: {
          src: ['**/*.html'],dest: 'dist',cwd: 'app',expand: true,}
}

关于angular2:如何通过条件手动将css文件添加到index.html?的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于android – 手动将本地文件添加到下载应用程序、Android:如何手动将文件添加到apk?、Angular 10:如何创建动态Component / html?、Angular 2 Typescript编译器复制html和css文件等相关内容,可以在本站寻找。

本文标签: