小编Man*_*ush的帖子

如何在ngOnInit()之前停止调用ngOnChanges

在我的角度应用程序中,我提出了一种情况,只有在输入绑定到更改时才应调用ngOnchanges.那么,有没有办法在ngOnInit之前停止执行ngOnChanges.有没有办法实现这一目标.提前致谢.

angular

23
推荐指数
1
解决办法
1万
查看次数

为什么angular 2 ngOnChanges没有响应输入数组推送

我的角度应用程序遇到了问题,我使用input作为数组,并在click事件出现时将值推送到数组.但是当数组推送完成时,ngOnChanges不会触发.有没有办法解雇ngOnChange

我的代码是ts文件

@Component({
  selector: 'adv-search',
  templateUrl: './app/modules/result.html'
})

export class InputComponent {
  @Input() metas:any=[];

  ngOnChanges() {
    console.log(this.metas);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的选择标签

<adv-search [metas] = "metaIds"></adv-search>
Run Code Online (Sandbox Code Playgroud)

单击事件代码

insertIds(id:any) {
   metaIds.push(id);
}
Run Code Online (Sandbox Code Playgroud)

angular2-template ngonchanges angular

23
推荐指数
3
解决办法
1万
查看次数

如何使用innerHTML在角度2中附加HTML内容

我使用innerHTML在我的组件中呈现HTML内容.但是innerHTML删除HTML内容中的所有属性(例如:删除样式属性)并呈现它.但需要按原样呈现,并且不希望从HTML内容中提取任何属性.是否有任何与innerHTML等效的内容,或者我们是否可以使用innerHTML完成所需的结果.提前致谢.

我的模板文件

<div id="more-info-box" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Title</h4>
            </div>
            <div class="modal-body">
                <div class="clearfix">
                    <div [innerHTML]="htmlContent" class="long-desc-wrap">
                    </div>
                </div>
            </div>
         </div>
    </div>
</div><!-- End Info box -->
Run Code Online (Sandbox Code Playgroud)

我的组件文件

import { Component } from '@angular/core';


@Component({
  selector: 'cr-template-content',
  templateUrl: './app/channel.component.html'
})
export class TemplateComponent {
  constructor() {

  }

  htmlContent = '<p>This is my <strong style="color:red">Paragraph</strong></p>'

}
Run Code Online (Sandbox Code Playgroud)

我当前的输出是没有样式属性的内容.但是期望的结果应该是style属性.

innerhtml angular2-template angular

9
推荐指数
2
解决办法
3万
查看次数

在angular 2中使用system.config.js文件有什么用?

var map,packages,var config是做什么的.并且还解释了map和package对象的所有配置属性.是否有可用配置的文档?

这是我的系统配置文件

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs': …
Run Code Online (Sandbox Code Playgroud)

node.js systemjs angular

8
推荐指数
2
解决办法
6826
查看次数

为什么通过拖放进行复制在 vscode 中不起作用

我更新了我的 vscode,他们在 2017 年 3 月的发行说明中提到了这一点。

Copy with drag and drop - Choose whether to copy or cut when you drag and drop in the editor.
Run Code Online (Sandbox Code Playgroud)

为什么我的 vscode 在拖放所选文本时不复制或剪切。我是否需要安装任何扩展才能使其工作。

visual-studio-code

6
推荐指数
2
解决办法
8242
查看次数

如何将angular5应用程序部署到子目录

我的角度应用程序托管在服务器中,其中应用程序URL为http://xyz.domain.in(示例网址)。现在,我在其中创建了子目录来托管另一个应用程序。但是,当我尝试访问类似http://xyz.domain.in/subfolder的路径时,请在控制台中获取它。

错误:无法匹配任何路线。网址段:“子文件夹”

子文件夹中的应用程序的基本href是

<base href="./subfolder">
Run Code Online (Sandbox Code Playgroud)

如何做到这一点?

production-environment angular ng-build

6
推荐指数
3
解决办法
2918
查看次数

如何在角度2中使用文件系统(fs)

在我的angular 2应用程序中,需要使用文件系统将大文件上传到Amazon S3服务器.但是,我在应用程序中导入文件系统时遇到问题.请帮助我的应用程序中实现文件系统.

我的component.ts文件

import { Component,ViewChild } from '@angular/core';
import * as fs from 'fs';
/* External Services */
import { ApiWebConfig } from '../../../core/config/app.config';

declare var $:any;
@Component({
  selector: 'content-uploadpart',
  templateUrl: './app/modules/uploadpartcontent.html'
})
export class ContentUploadPartComponent {
  constructor( private config:ApiWebConfig ) { }  
  uploadToAWS(file:any) {
    var buffer = fs.readFile() 
    console.log('buffer',buffer);
  }
  ngOnInit() { }
}
Run Code Online (Sandbox Code Playgroud)

还有我的uploadpartcontent.html

<div class="container">
    <div class="row">
        <div class="col-md-12 upload_part_wrap">
            <input #fileUpload (change)="uploadToAWS($event)" type="file" value="Browse" />
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的Package.json文件

{
  "name": "my-project",
  "version": "1.0.0", …
Run Code Online (Sandbox Code Playgroud)

filesystems fs aws-sdk fs-extra angular

5
推荐指数
0
解决办法
8522
查看次数

如何在反应formik中检查提交时表单是否有效

我在我的项目中使用了formik库。还使用 yup 库进行表单字段验证。我想在连接到提交方法的 api 之前检查表单是否有效。下面是我的项目中使用的代码。

<Formik
                    isInitialValid = {false}
                    initialValues={this.formData}
                    validationSchema={CRYP_LOGIN_SCHEMA}
                    onSubmit={this.loginSubmit.bind(this)}>
                    {({ errors, status, touched, isValid }) => (
                        <Form  className="login_reg_form">
                            <div className="input_control_wrp mb-4">
                                <div className="input_control">
                                    <span className="left_icon"><i className="fas fa-user"></i></span>
                                    <Field placeholder="Enter your Email" name="email" />
                                </div>
                                {errors.email && touched.email && <span className="mt-1 input_error">{errors.email}</span>}
                            </div>

                            <div className="input_control_wrp mb-2">
                                <div className="input_control">
                                    <span className="left_icon"><i className="fas fa-key"></i></span>
                                    <Field type={this.state.pwdType} placeholder="Enter your Password" name="password" />
                                    <a
                                     onClick={this.togglePwdType.bind(this)}
                                     href="javascript:void(0)"
                                     className="right_icon">
                                        <i className={this.state.pwdType == 'password' ? 'fas fa-eye' : 'fas fa-eye-slash'}></i>
                                     </a>
                                </div>
                                {errors.password && …
Run Code Online (Sandbox Code Playgroud)

forms validation reactjs yup formik

5
推荐指数
1
解决办法
2万
查看次数