在我尝试时,AsyncTask我从我的服务器获取电子邮件地址.在onPostExecute()我必须检查是电子邮件地址empty或null.我使用以下代码来检查它:
if (userEmail != null && !userEmail.isEmpty()) {
Toast.makeText(getActivity(), userEmail, Toast.LENGTH_LONG).show();
UserEmailLabel.setText(userEmail);
}
Run Code Online (Sandbox Code Playgroud)
但在我Toast看来null是印刷的.我的完整代码:
private class LoadPersonalData extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
protected Void doInBackground(String... res) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("user_id", PrefUserName));
params.add(new BasicNameValuePair("type", type_data));
JSONObject json = jsonParser.makeHttpRequest(Url, "POST", params);
String result = "";
try {
result = json.getString("message");
} catch (JSONException e) {
e.printStackTrace();
}
if …Run Code Online (Sandbox Code Playgroud) 我正在form使用组件添加输入字段 -
发动机附加接触form.html
<form (ngSubmit)="onSubmit()" [formGroup]="contact_form">
<md-tab-group>
<md-tab label="Form">
<ang-form></ang-form>
</md-tab>
<md-tab label="Email">
<ang-email></ang-email>
</md-tab>
<md-tab label="Message">
<ang-message></ang-message>
</md-tab>
</md-tab-group>
<button md-raised-button type="submit">Publish</button>
Run Code Online (Sandbox Code Playgroud)
ANG-form.html
<div class="form-grid form-title">
<md-input-container>
<input formControlName="contact_form_title"
class="form-title-field" mdInput placeholder="Title" value="">
</md-input-container>
</div>
Run Code Online (Sandbox Code Playgroud)
使用相同的方式我添加了其他组件(ang-email ang-message)html.
我添加了[formGroup]指令engine-add-form.ts
export class EngineAddFormComponent{
contact_form: any;
form_value: any;
constructor(){
this.contact_form = new FormGroup({
contact_form_title: new FormControl('', Validators.minLength(2)),
........
........
});
}
onSubmit(){
this.form_value = JSON.stringify(this.contact_form.value);
console.log(this.form_value);
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误 -
错误:formControlName必须与父formGroup指令一起使用.您将要添加formGroup指令并将其传递给现有的FormGroup实例(您可以在类中创建一个).
我无法理解我的代码有什么问题.
我创建了一些动态组件,如 -
<div>
<ang-textfield></ang-textfield>
<ang-textarea></ang-textarea>
<ang-checkbox></ang-checkbox>
</div>
Run Code Online (Sandbox Code Playgroud)
具体而言dynamic component,有一些元素,如 -
<ang-textfield>
<input type="text" />
<button>Settings</button>
<button (click)="remove_component()">Remove</button>
</ang-textfield>
Run Code Online (Sandbox Code Playgroud)
我想在点击Remove按钮后删除当前组件.
我怎样才能做到这一点?
这是掠夺者
我怎样才能得到ViewRef我当前的component-
我正在尝试ViewRef从服务中获取。这是代码 -
组件.service.ts
import { Injectable, ViewRef } from '@angular/core';
@Injectable()
export class CheckboxService{
constructor(private viewRef: ViewRef){
}
getViewRef(){
return this.viewRef;
}
}
Run Code Online (Sandbox Code Playgroud)
组件.ts
import { Component, EventEmitter, Output, ViewChild, ViewRef } from
'@angular/core';
import { AddFormDirective } from '../../add-form/add-form.directives';
import { CheckboxService } from './checkbox.service';
@Component({
selector: 'ang-checkbox',
templateUrl: './checkbox.component.html'
})
export class CheckboxViewComponent {
@ViewChild(AddFormDirective) addFormDirective: AddFormDirective;
constructor(private checkboxService: CheckboxService){
}
remove_element(){
let viewContainerRef = this.addFormDirective.viewContainerRef;
let currentComponentIndex =
viewContainerRef.indexOf(this.checkboxService.getViewRef());
viewContainerRef.remove(currentComponentIndex); …Run Code Online (Sandbox Code Playgroud) 在我的PHP项目中 - 我正在尝试js使用 webpack 和 babel 构建我的文件。有 3 个js文件 - config.js helper.js script.js. 他们互相依赖。helper.js依赖于config.js且script.js依赖于helper.js。
config.js:
module.exports = {
const DG_GRAPH_TYPE = 'line';
const DG_XAXIS_TICKS = 4;
const DG_SINGLE_POST_GRAPH_CANVAS_HEIGHT = 250;
......
helper.js:
const config = require('./config');
module.exports = {
......
script.js:
const helper = require('./helper');
jQuery(document).ready(function ($) {
......
Run Code Online (Sandbox Code Playgroud)
这是我的wepack.config.js文件,我在其中配置了以下代码:
const path = require('path');
module.exports = {
entry: {
script: [
'./assets/js/script.js'
] …Run Code Online (Sandbox Code Playgroud) 我是新的Phonegap发展.在我当前的项目中,我想获取用户个人资料名称,Gmail和电子邮件地址.我知道如何以原生方式检索这些信息Android.通过使用哪个插件,我可以获得这些信息Phonegap.提前致谢.
我正在尝试h1使用以下代码更改via的文本
document.getElementById("wpbody-content").getElementsByClassName("wrap").getElementsByTagName('h1')[0].innerHTML = 'Application Forms';
Run Code Online (Sandbox Code Playgroud)
这是HTML代码
document.getElementById("wpbody-content").getElementsByClassName("wrap").getElementsByTagName('h1')[0].innerHTML = 'Application Forms';
Run Code Online (Sandbox Code Playgroud)
但它显示我以下错误
TypeError: document.getElementById(...).getElementsByClassName(...).getElementsByTagName is not a function
Run Code Online (Sandbox Code Playgroud)