考虑完全简单的Angular 2服务:
import { Injectable } from '@angular/core';
import {Category} from "../models/Category.model";
@Injectable()
export class CategoryService {
activeCategory: Category|{} = {};
constructor() {};
}
Run Code Online (Sandbox Code Playgroud)
然后使用此服务的组件:
import { Component, OnInit } from '@angular/core';
import {CategoryService} from "../shared/services/category.service";
import {Category} from "../shared/models/Category.model";
@Component({
selector: 'my-selector',
template: `
{{categoryService.activeCategory.Name}}<br/>
{{category.Name}}<br/>
`,
})
export class MySelectorComponent implements OnInit {
category:Category|{} = {};
constructor(public categoryService:CategoryService){};
ngOnInit() {
this.category = this.categoryService.activeCategory;
};
}
Run Code Online (Sandbox Code Playgroud)
假设适当定义的Category模型并假设某个地方的另一个组件在某个时刻将服务上的activeCategory设置为有效的Category.假设类别服务被设置为适当更高级别的提供者.
当发生这种情况时,模板中的第一行将正确显示类别名称,但第二行不会.我尝试过使用getter和setter与原始访问服务; 我尝试过原始类型与对象和对象属性; 我无法相信第一行是适合此类访问的范例.有人能告诉我将服务属性绑定到组件属性的最简单方法,该属性将正确地改变角度2中的跟踪吗?
澄清:我知道我可以使用我创建并为自己推动的可观察量.我要问的是,是否有任何已经融入框架的方法(这不需要我为可观察量编写大量的样板),只是在服务和组件之间建立一个可变轨道.
在看板视图中,列的顶部显示每列中的多个工作项。我更希望它显示该列中工作项的故事点的总和。除此之外,我正在寻找最简单的报告/视图/任何能够向我显示网格每列中的故事点数量的东西。
刚刚从 JIRA 切换到 Azure Devops,我感觉这个产品在不需要的地方都过于复杂,并且没有足够的功能来满足基本的敏捷使用。如果有任何能让转换变得更加愉快/让 Azure Devops 中类似 JIRA 的行为成为可能的建议,我们将不胜感激。
我有一个ng-repeat,只要现有的"last"元素以任何方式被修改,它就会添加一个新元素.我的量角器测试看起来像这样:
var emptyPerson = this.people.last() // this gets me the last row of the ng-repeat
emptyPerson.element(by.css('.firstName')).sendKeys('first'); // this sets the firstname correctly but then the app adds a new row to the ng-repeat because of the model change here.
emptyPerson.element(by.css('.lastName')).sendKeys('last'); // this sets the lastname of the new row instead of the row that emptyPerson previously referenced
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉emptyPerson坚持使用相同的元素,直到我们完成它为止?
编辑firstname之前的HTML示例:
<div ng-repeat="person in object.People" class="student ng-scope">
<div type="text" ng-model="person.FirstName" skip-label="true" placeholder="First" validator="svalidators[$index]" class="layout-default field field-FirstName type-text">
<input type="text" ng-focus="myFocus()" ng-blur="myBlur()" class="form-control" …Run Code Online (Sandbox Code Playgroud)