小编Man*_*dha的帖子

如何将现有的非 git 项目添加到 bitbucket

我使用 angular cli 创建了一个项目。项目在目录中dw-ng2-app,它有几个由 angular cli 生成的文件。我想为此创建一个 Bitbucket 存储库。我的困惑是,当我在 Bitbucket 中创建存储库时,它给了我 3 个选项

  1. 我创建了一个 README 和 .gitignore 文件。我无法使用此选项,因为当我尝试将本地项目与存储库同步时,出现没有共同历史记录的错误
  2. 我选择了从头开始的选项。该网页列出了我应该运行以克隆和上传的命令,例如,git clone git@bitbucket.org:username/angularcli.git 但这会在我的本地计算机上创建一个名为 angularcli 的新目录,该目录具有 .git 目录。我不确定是否可以使用此选项,因为我的项目位于不同的目录中,将其移动到 angularcli 目录可能会影响它(不确定)
  3. 第三个选项是提到我有一个现有的项目。然后我被提示使用该命令,git remote add origin ssh://git@bitbucket.org/username/angularcli.git但这不起作用,因为我当前的项目目录不是 git 存储库

如何将 angular cli 项目移动到 bitbucket?我应该先创建存储库,然后在生成的目录中创建 angularcli 项目吗?

bitbucket

7
推荐指数
1
解决办法
5694
查看次数

在组件的 html 中使用 id 属性可以吗?

c考虑一个组件html

<form id="someID"[formGroup]="codeEditorForm" novalidate>
</form>
Run Code Online (Sandbox Code Playgroud)

css

#SomeID{
color:grey;
}
Run Code Online (Sandbox Code Playgroud)

如果C被包含在父组件中P两次,那么是否也会id被复制,这不应该发生在html

问题 1 - 我不应该使用idinAngular吗?问题2-我该如何在css不使用的情况下编写规则id

html css angular6

6
推荐指数
1
解决办法
2405
查看次数

如何在Intellij中按顺序运行多个配置

我的应用程序具有以下配置/SBT 任务: - 构建 UI - 构建服务器 - 运行 UI 测试 - 运行服务器端测试 - 创建应用程序的分发版本。

我想创建一个按顺序运行所有这些的配置,但如果之前的任何配置失败则停止。

我创建了一个使用其他配置的配置,但它不会在第一个配置之后移动到下一个配置。

在此输入图像描述

我还尝试创建一个复合配置,但无法指定顺序/顺序,因为它并行运行所有配置。

有没有办法根据先前配置的结果依次运行多个配置?

intellij-idea

6
推荐指数
0
解决办法
1816
查看次数

TemplateRef 中未定义 ElementRef

在 Angular 中试验 ElementRef、TemplateRef、ViewRef 和 ViewContainerRef。我已经创建了一个 HTML 模板,我想从那里创建一个视图并将该视图传递给 ViewContainerRef 但它不起作用

模板代码

template: `
  <ng-container #vc></ng-container>
  <ng-template #mytmpl>
    <div>Name: <input type="text" name="name" /> </div>
    <div>Gender: 
      <select  name="gender" >
        <option>Male(1)</option>
        <option>Female(2)</option>
      </select>
    </div>
    <div>About you: <textarea ></textarea></div>
    <div>Married: <input type="checkbox" /></div>      
    <div>Children:     
      <ng-container *ngFor = "let option of this.selectOptions">
        <input  type="radio" [id]="option" name="children" [value]=option [(ngModel)]="this.children"/> {{option}}
      </ng-container>
   </div>
   <p>Some para</p>
   <p>Para with span <span>Inside span</span></p>
  </ng-template>
`
Run Code Online (Sandbox Code Playgroud)

在课堂上,我访问模板和视图容器

@ViewChild('vc',{read:ViewContainerRef}) v:ViewContainerRef;
@ViewChildren("mytmpl") myTemplateList:TemplateRef<any>;
Run Code Online (Sandbox Code Playgroud)

我使用以下代码来创建视图

ngAfterViewInit(){
  let elementRef = this.myTemplateList.elementRef
  let view = this.myTemplateList.createEmbeddedView(null) …
Run Code Online (Sandbox Code Playgroud)

angular

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

为什么 Manifest 被弃用了?什么时候应该使用 ClassTag,什么时候应该使用 TypeTag

我有几个关于Manifest和 的问题TypeTag。据我了解,JVM 不了解泛型并删除类型。所以我不能这样做

def factoryForAll[T] = new T // will not compile. Runtime doesn't know what T is
Run Code Online (Sandbox Code Playgroud)

Scala 编译器可以使用Manifest(现已弃用)将有关类型的信息传输到运行时。有类似包含类型信息的Manifest方法。erasure所以我可以执行以下操作来创建通用类型 T 的对象

def factoryForall[T](implicit ev:Manifest[T]) = ev.erasure.newInstance

scala> factoryForAll[String]
res1:Any=""

scala> class C
defined class C

scala> factoryForAll[C]
res5: Any = C@52cb52bd
Run Code Online (Sandbox Code Playgroud)

问题 1 - 有趣的是,它不适用于 Int (或 Float)?为什么?

scala> factoryForAll[Int]
java.lang.InstantiationException: int
Run Code Online (Sandbox Code Playgroud)

问题 2 - 为什么 Manifest 被弃用?我知道新版本TypeTag有更丰富的信息,但我不明白 Manifest 的缺点是什么

问题 3 - Scala 2.12 仍然有Manifest …

scala

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

为什么指令选择器在`[]中

我注意到,指令的选择器通常在中指定,[]但不带[]括号使用。为什么?

@Directive({
  selector: '[appGoWild]'
})
export class GoWildDirective implements OnInit {
  constructor(private renderer: Renderer2, private el: ElementRef) {}

  ngOnInit() {
    this.renderer.addClass(this.el.nativeElement, 'wild');
  }
}
Run Code Online (Sandbox Code Playgroud)

HTML中的用法

<h1 appGoWild>
  Hello World!
</h1>
Run Code Online (Sandbox Code Playgroud)

angular

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

.ts 文件可以包含多个类吗

我想创建一个.ts包含我的数据模型的文件。每个数据模型都映射到一个JSON我将从服务器发送或接收的数据。例如。对于用户个人资料,Json 是

 {
  "firstname" : "d",
  "lastname" : "d",
  "email" : "dd",
  "password" : "d"
}
Run Code Online (Sandbox Code Playgroud)

对于上面的内容,我想创建一个类,如下所示

export class UserProfile {

  constructor (public firstname:string,
               public lastname:string,
               public email:string,
               public password:string){}
}
Run Code Online (Sandbox Code Playgroud)

服务器可能发送的另一个 JSON 是

{
result:"success"
addition-info:"something"
}
Run Code Online (Sandbox Code Playgroud)

上面的类是

export class Result{

  constructor (public result:string,
               public additionalInfo:string){}
}
Run Code Online (Sandbox Code Playgroud)

Angular 中是否有关于如何为数据模型创建文件的最佳实践?我可以创建一个.ts文件BackendApiModels.ts来存储所有类,还是应该.ts为每个数据模型创建一个文件?我什至不知道是否可以创建一个.ts可以包含多个类的文件,例如

后端API

 export class UserProfile {

      constructor (public firstname:string,
                   public lastname:string,
                   public email:string,
                   public password:string){}
    }

    export class Result{ …
Run Code Online (Sandbox Code Playgroud)

angular5

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

如何在Intellij中更正错误导入的项目。收到错误-不是有效的项目ID

我克隆了仓库,并使用现有仓库,build.sbt将项目导入了Intellij(我不记得这样做时使用的设置)。我注意到Intellij该项目有一个自己web_3075的名称- 而我的项目名称是TestProjectname := "TestProject")。现在,当我尝试编译项目时,出现了错误Not a valid project ID: web_3075。我该如何解决这个问题?

我可以安全地删除.idea文件并再次导入项目吗?

intellij-idea sbt

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

如何在 OpenAPI 3.0 的架构中使用 $ref?

我想schema在 OpenAPI 3.0 API 定义中将以下 JSON 表示为 a :

{
get-question: {
  question-id:string
  }
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经写了:

{
get-question: {
  question-id:string
  }
}
Run Code Online (Sandbox Code Playgroud)

但我在 Swagger 编辑器中收到这些错误:

Schema error at components.schemas['GetQuestion']
should have required property '$ref'
missingProperty: $ref
Jump to line 79
Schema error at components.schemas['GetQuestion']
should match exactly one schema in oneOf
Jump to line 79
Schema error at components.schemas['GetQuestion'].properties['get-questions']
should have required property '$ref'
missingProperty: $ref
Jump to line 81
Schema error at components.schemas['GetQuestion'].properties['get-questions']
should match exactly one …
Run Code Online (Sandbox Code Playgroud)

openapi

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

如何从 Angular 规范触发输入 onchange

我有一个input HTML File归档

<input type="file" class="custom-file-input" id="question-file-upload" formControlName="image" (change)="handleFileSelect($event)">
Run Code Online (Sandbox Code Playgroud)

我想对handleFileSelect功能进行单元测试。但我不知道如何触发onChange输入的方法。以下是spec我写的,但出现错误imageInputNE.onchange is not a function

fit('should keep track of image counter when an image is loaded', () => {
    let newPracticeQuestionComponent = component;
    expect(newPracticeQuestionComponent.currentImageAttachmentCount).toBe(0);
    let imageInputDE = fixture.debugElement.query(By.css("#question-file-upload"));
    expect(imageInputDE).toBeTruthy();
    spyOn(newPracticeQuestionComponent,'handleFileSelect');

    let imageInputNE:HTMLElement = imageInputDE.nativeElement as HTMLElement;
    imageInputNE.onchange(new Event("some event"));
    expect(newPracticeQuestionComponent.handleFileSelect).toHaveBeenCalled();


  });
Run Code Online (Sandbox Code Playgroud)

angular angular-test angular6

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