我想在angular中实现一个简单的拖放列表,例如我可以更改其订单的杂货清单.
我在使用https://github.com/akserg/ng2-dnd之前实现了它,但我的问题是我使用angular 2.0.0-beta.15
而且我目前无法升级它所以我必须找到支持这个版本的东西.我试图寻找这个库的特定提交,并没有任何适合我的版本.我需要那种确切的行为.这个库的更具体的例子是.也许有人知道我自己可以做到这一点,无论如何都会很好,更喜欢一些图书馆以节省时间.
(即时通讯使用打字稿)
如果有人以其他方式使用其他方式重新排序列表,并且可以给出一个也将受到祝福的例子.
我有一个 json 查询,它为我提供了人和宠物的连接表的 json:
SELECT json_object(
'personId', p.id,
'pets', json_arrayagg(json_object(
'petId', pt.id,
'petName', pt.name
))
)
FROM person p LEFT JOIN pets pt
ON p.id = pt.person_id
GROUP BY p.id;
Run Code Online (Sandbox Code Playgroud)
我的问题是这个人可以有 0 只或更多宠物,当一个人有 0 只宠物时,我会得到 1 个空宠物的列表,在这种情况下我想得到的是空列表。
这就是我得到的:
{
"personId": 1,
"pets": [
{
"petId": null,
"petName": ""
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要:
{
"personId": 1,
"pets": []
}
Run Code Online (Sandbox Code Playgroud)
那可能吗?
我想永久删除一个pod,所以我可以再次从fresh创建deployment.yaml和derveice.yaml,所以我尝试了:
kubctl delete pod <pod>
Run Code Online (Sandbox Code Playgroud)
并且pod仍在那里,也尝试过:
kubectl delete pods <pod> --grace-period=0
Run Code Online (Sandbox Code Playgroud)
并没有奏效.
唯一有效的是当我设置部署replicas: 0
然后应用它时,但是当我尝试创建新部署时,我得到:
服务器出错:创建"myService/deployment.yaml"时出错:deployments.extensions"myService"已经存在
deployment google-cloud-endpoints kubernetes kubernetes-health-check
我有一个特性扩展了两个具有相同名称的函数,但它与内部有点不同,我想知道如何知道将调用哪个函数?
我有特点B
有print()
,和特质C
有print()
,如果我继承了他们两个这样的:
trait A extends B with C {
def print()
}
Run Code Online (Sandbox Code Playgroud)
每个打印打印别的东西,哪个打印会被调用?
我有一个项目,我有一个简单的客户端用angularjs编写,服务器在scala中,在我的客户端我有一个简单的上传按钮,你点击它并选择一个本地文件(csv),当我上传一个特定的csv这有点大,就像我得到的6000行
413请求实体太大
我上传的js代码是:
$scope.upload = function(files) {
if (!files || !files.length) {
} else {
for (var i = 0; i < files.length; i++) {
var file = files[i];
Upload.upload({
url: '/uploadFile',
file: file
}).
}).success(function (data, status, headers, config) {
}).error(function (data, status, headers, config) {
$scope.showServerError(status, data);
})
}
}
};
Run Code Online (Sandbox Code Playgroud)
在服务器中是:
def uploadFile = Action(parse.multipartFormData) { implicit request =>
request.body.file("file").fold {
BadRequest("Missing file")
} { uploadedFile => {
val localFile = new File("/tmp/" + uploadedFile.ref.file.getName)
Files.copy(uploadedFile.ref.file.toPath, localFile.toPath, …
Run Code Online (Sandbox Code Playgroud) 我有以下3个案例类:
case class Profile(name: String,
age: Int,
bankInfoData: BankInfoData,
userUpdatedFields: Option[UserUpdatedFields])
case class BankInfoData(accountNumber: Int,
bankAddress: String,
bankNumber: Int,
contactPerson: String,
phoneNumber: Int,
accountType: AccountType)
case class UserUpdatedFields(contactPerson: String,
phoneNumber: Int,
accountType: AccountType)
Run Code Online (Sandbox Code Playgroud)
这只是枚举,但是我还是添加了:
sealed trait AccountType extends EnumEntry
object AccountType extends Enum[AccountType] {
val values: IndexedSeq[AccountType] = findValues
case object Personal extends AccountType
case object Business extends AccountType
}
Run Code Online (Sandbox Code Playgroud)
我的任务是-我需要编写一个funcc Profile
,并将UserUpdatedFields(所有字段)与BankInfoData中的某些字段进行比较...此功能是查找要更新的字段。
所以我写了这个函数:
def findDiff(profile: Profile): Seq[String] = {
var listOfFieldsThatChanged: List[String] = List.empty
if (profile.bankInfoData.contactPerson != profile.userUpdatedFields.get.contactPerson){
listOfFieldsThatChanged …
Run Code Online (Sandbox Code Playgroud) 我有一个 api 函数,它执行 post 并返回 ModelAResponse 的 Observable (我拥有的接口)
我希望两个根据返回的状态返回 ModelAResponse 或 B 的 Observable。
这是我的两个响应模型:
export interface ModelAResponse {
res: ModelA;
}
export interface ModelBResponse {
res: ModelB
}
Run Code Online (Sandbox Code Playgroud)
(ModelA、ModelB是放置在另一个类中的接口)
所以目前我只支持模型 a 的一次返回:
public myApiFunc(req: MyRequestModel): Observable<ModelAResponse> {
...
this.http.post("my/api/path", req, {headers: myHeaders}),
(jsonReturned) => status === 200 ? {res: jsonReturned} : undefined);
...
}
Run Code Online (Sandbox Code Playgroud)
如何更改此函数以根据打字稿最佳实践方式的状态返回 ModelAResponse 或 ModelBResponse?
我有三个按钮,显示三个不同的列表,所以我想添加enum
s来帮助我决定使用哪个列表ngSwitch
,但是我收到了一个错误.
这是TypeScript:
export enum ListType {People, Cars}
export class AppCmp implements OnInit {
listOfPeople: Person[];
listOfCars: Car[];
currentListView: CurrentListView;
constructor(private _MyService: MyService) {
};
public setListType(type: ListType) {
this.listType = type;
}
ngOnInit() {
this._MyService.getListOfPeopleData().subscribe(res => {
this.listOfPeople = res;
});
this._MyService.getListOfCarsData().subscribe(res => {
this.listOfCars = res;
});
}
}
Run Code Online (Sandbox Code Playgroud)
这是HTML:
<div>
<button md-button
(click)="setListType(listType.People)"
class="md-primary">People
</button>
<button md-button
(click)="setListType(listType.Cars)"
class="md-primary">Cars
</button>
</div>
<md-content>
<h1 align="center">{{title}}</h1>
<div [ngSwitch]="currentListView">
<div *ngSwitchCase="listType.People">
<div class="list-bg" *ngFor="#person of listOfPeople">
ID: …
Run Code Online (Sandbox Code Playgroud) angular ×3
scala ×3
typescript ×3
angularjs ×2
deployment ×1
enums ×1
html5 ×1
http ×1
inheritance ×1
java ×1
javascript ×1
kubernetes ×1
mysql ×1
rxjs ×1
traits ×1