是否有任何不那么复杂的方法在角度2中进行确认对话,想法是点击一个项目,然后显示一个弹出窗口或模态以确认其删除,我尝试角度2模态从这里angular2-modal,但如果你确认或取消它,我不知道如何做到这一点.点击功能工作正常,唯一的问题是我不太清楚如何使用它.我还有另一个带有相同插件的模态,与我使用的不同.
this.modal.open(MyComponent);
Run Code Online (Sandbox Code Playgroud)
而且我不想创建另一个组件只是为了显示一个确认框,这就是我要问的原因.
我可以看到在使用表单时如何向字段添加错误消息,但是模型表单呢?
这是我的测试模型
class Author(models.Model):
first_name = models.CharField(max_length=125)
last_name = models.CharField(max_length=125)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
Run Code Online (Sandbox Code Playgroud)
我的模特形式
class AuthorForm(forms.ModelForm):
class Meta:
model = Author
Run Code Online (Sandbox Code Playgroud)
字段:first_name和last_name上的错误消息是"此字段是必需的".如何在模型表单中更改它?
我正在使用angular2-google-mapsAngular2的最新版本.我试图将一些本地地图组件功能转换为自己文件中的服务maps.service.ts.例如:
map.component.ts
getGeoLocation(lat: number, lng: number) {
if (navigator.geolocation) {
let geocoder = new google.maps.Geocoder();
let latlng = new google.maps.LatLng(lat, lng);
let request = { latLng: latlng };
geocoder.geocode(request, (results, status) => {
if (status == google.maps.GeocoderStatus.OK) {
let result = results[0];
if (result != null) {
this.fillInputs(result.formatted_address);
} else {
alert("No address available!");
}
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
变成这样的东西: maps.service.ts
getGeoLocation(lat: number, lng: number): Observable<google.maps.GeocoderResult[]> {
let geocoder = new google.maps.Geocoder();
let latlng = new …Run Code Online (Sandbox Code Playgroud) google-maps typescript angular-cli angular2-google-maps angular
我实际上开始尝试了解有关MongoDB的更多信息,但是我已经挂断了.NET等待/异步的东西.我正在尝试实现MongoDB 网站上显示的代码.我不得不稍微修改它,所以我可以让我的程序编译.我知道有以下我的控制台应用程序.
protected static IMongoClient _client;
protected static IMongoDatabase _database;
static void Main(string[] args)
{
_client = new MongoClient();
_database = _client.GetDatabase("test");
GetDataAsync();
}
private static async void GetDataAsync() //method added by me.
{
int x = await GetData();
}
private static async Task<int> GetData()
{
var collection = _database.GetCollection<BsonDocument>("restaurants");
var filter = new BsonDocument();
var count = 0;
Func<int> task = () => count; //added by me.
var result = new Task<int>(task); //added by me.
using (var cursor …Run Code Online (Sandbox Code Playgroud) 我想在生成某个视图时在控制器中将bool设置为true,然后相应地更改视图的标题.这应该是简单的,但我得到:
无法对空引用执行运行时绑定异常详细信息:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:无法对空引用执行运行时绑定
我正在做的就是控制器:
[AllowAnonymous]
public ActionResult Register()
{
ViewBag.IsRegistration = true;
return View();
}
Run Code Online (Sandbox Code Playgroud)
然后在视图中:
@if (ViewBag.IsRegistration)
{
<legend>Register using another service.</legend>
}
else
{
<legend>Use another service to log in.</legend>
}
Run Code Online (Sandbox Code Playgroud)
但它失败了:
@if (ViewBag.IsRegistration)
Run Code Online (Sandbox Code Playgroud)
UPDATE
相关控制器代码:
[AllowAnonymous]
public ActionResult Register()
{
ViewBag.IsRegistration = "true";
return View();
}
Run Code Online (Sandbox Code Playgroud)
注册视图:
@model Mvc.Models.RegisterViewModel
@{
Layout = "~/Views/Shared/_AccountLayout.cshtml";
ViewBag.Title = "Register";
}
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
</hgroup>
<div class="row">
<div class="col-lg-6">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<fieldset class="form-horizontal">
<legend>Create a new account.</legend>
<div class="control-group"> …Run Code Online (Sandbox Code Playgroud) 安装 EsLint 后,我看到的错误之一如下:
Prop spreading is forbiddeneslint(react/jsx-props-no-spreading)
I want to create a rule in the EsLint configuration to ignore this error but the examples I found do not work.
This is the format to create a global exception:
...
"react/jsx-props-no-spreading": [{
"html": "ignore" / "enforce",
"custom": "ignore" / "enforce",
"exceptions": [<string>]
}]
...
Run Code Online (Sandbox Code Playgroud)
And this is the format to create an exception in a specific file:
{
"rules": {...},
"overrides": [
{
"files": ["*-test.js","*.spec.js"],
"rules": {
"no-unused-expressions": "off"
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个计时器:
initiateTimer() {
if (this.timerSub)
this.destroyTimer();
let timer = TimerObservable.create(0, 1000);
this.timerSub = timer.subscribe(t => {
this.secondTicks = t
});
}
Run Code Online (Sandbox Code Playgroud)
如何在60分钟后向用户添加弹出窗口?我已经尝试过看几个问题(这个和这个),但它不是为了点击我.RxJS模式还是新手......
我试图CountIf在可见细胞上的vba中使用一个函数来计算所有可见的单元格yes,有25个,但是我得到了错误
无法获得班级的
CountIf财产WorksheetFunction
它突出显示returnCount,不确定是否也有错误myrange,任何帮助将不胜感激.
Set myrange = _
Range("D4",Range("D4").End(xlDown)).SpecialCells(xlCellTypeVisible)
returnCount = WorksheetFunction.CountIf(myrange, "yes")
Run Code Online (Sandbox Code Playgroud) 我有这种反应性角形结构
myForm: FormGroup;
Personal: FormGroup;
FIRST_NAME: FormControl;
LAST_NAME: FormControl;
ngOnInit(): void {
this.createFormControls();
this.createForm();
}
createFormControls() {
this.FIRST_NAME = new FormControl('', [Validators.required]);
this.LAST_NAME = new FormControl('', [Validators.required]);
}
createForm(): void {
this.myForm = this.fb.group({
Personal: this.fb.group({
FIRST_NAME: this.FIRST_NAME,
LAST_NAME: this.LAST_NAME,
})
})
}
Run Code Online (Sandbox Code Playgroud)
如果我做
this.FIRST_NAME.disable();
Run Code Online (Sandbox Code Playgroud)
它禁用FormControl
如何禁用Personal FormGroup中的所有FormControls
Perl6文档表明,当比较一组中的两个项目时,===使用.这是来自perl6文档的引用:
允许任何类型的对象/值作为设置元素.在集合中,每个元素都保证是唯一的(在某种意义上,没有两个元素会与
===运算符进行正比较)
我想知道是否可以使用用户定义的函数而不是===?例如,我如何使用~~而不是===确定集合中的2个元素是否"相等".
我试图解决的问题是:集合A有一些名字和一些姓氏,但是所有的小写和没有标点符号,而集合B有许多名字和姓氏以任何顺序混合,并且那里可能是名称附带的标点符号,可能是大写或小写.我想知道集合A中的人(表示为具有一个特定名字和姓氏的A的子集)是否出现在集合B中.在这种情况下,===由于集合B中的字母案例和标点符号,我无法使用.
如果我可以使用~~而不是===,那么问题就会简单得多,因为我只需要确定A的子集是否也是B的子集~~.这类似于我之前提到的"置换匹配"问题.
非常感谢你 !
angular ×4
c# ×2
angular-cli ×1
asp.net-mvc ×1
asynchronous ×1
comparison ×1
django ×1
django-forms ×1
elements ×1
eslint ×1
excel ×1
excel-vba ×1
formgroups ×1
google-maps ×1
mongodb ×1
observable ×1
perl6 ×1
razor ×1
reactjs ×1
redux ×1
rxjs ×1
set ×1
timer ×1
typescript ×1
vba ×1