我有一个angular 5组件,需要在新选项卡中打开链接,我尝试了以下操作:
<a href="www.example.com" target="_blank">page link</a>
Run Code Online (Sandbox Code Playgroud)
当我打开链接时,应用程序变慢并打开如下路径:
localhost:4200/www.example.com
Run Code Online (Sandbox Code Playgroud)
我的问题是:正确地做到这一点的正确方法是什么?
我是角色的新手,我有以下情况,即我有一个服务getAnswers():Observable<AnswerBase<any>[]>和两个相互关联的组件.
online-quote组件getAnswers():Observable<AnswerBase<any>[]>在其ngOnInit()方法中调用服务,并将其结果传递给组件dynamic-form.
为了说明这种情况,这是我的两个组件的代码:
在线quote.component.html:
<div>
<app-dynamic-form [answers]="(answers$ | async)"></app-dynamic-form>
</div>
Run Code Online (Sandbox Code Playgroud)
在线quote.component.ts:
@Component({
selector: 'app-online-quote',
templateUrl: './online-quote.component.html',
styleUrls: ['./online-quote.component.css'],
providers: [DynamicFormService]
})
export class OnlineQuoteComponent implements OnInit {
public answers$: Observable<any[]>;
constructor(private service: DynamicFormService) {
}
ngOnInit() {
this.answers$=this.service.getAnswers("CAR00PR");
}
}
Run Code Online (Sandbox Code Playgroud)
动态form.component.html:
<div *ngFor="let answer of answers">
<app-question *ngIf="actualPage===1" [answer]="answer"></app-question>
</div>
Run Code Online (Sandbox Code Playgroud)
动态form.component.ts:
@Component({
selector: 'app-dynamic-form',
templateUrl: './dynamic-form.component.html',
styleUrls: ['./dynamic-form.component.css'],
providers: [ AnswerControlService ]
})
export class DynamicFormComponent implements OnInit { …Run Code Online (Sandbox Code Playgroud) rxjs typescript angular2-decorators angular2-observables angular
我是棱角分明的观察者的新手.我有一个问题想要在subscribe方法中返回一个值.我有以下方法(getFirebaseData(idForm:string):observable <any[]>):
getTotalQuestions(idForm:string){
let totalQuestions:number;
this.getFirebaseData(idForm+"/Metadatos")
.subscribe(items =>
{
items.map(item => {
totalQuestions=item.Total;
console.log(totalQuestions);
});
}
);
console.log(totalQuestions);
return totalQuestions;
}
Run Code Online (Sandbox Code Playgroud)
firts console.log(totalQuestions)打印4但第二次console.log(totalQuestions)打印未定义.我理解subscribe是一个异步操作,因此第二个console.log(totalQuestions)("为了编写代码")打印未定义,但我找不到在subscribe方法完成后返回变量的方法.现在,如果我更改订阅地图:
getTotalQuestions(idForm:string){
let totalQuestions:number;
this.getFirebaseData(idForm+"/Metadatos")
.subscribe(items =>
{
items.map(item => {
totalQuestions=item.Total;
console.log(totalQuestions);
});
}
);
console.log(totalQuestions);
return totalQuestions;
}
Run Code Online (Sandbox Code Playgroud)
firts console.log(totalQuestions)没有打印任何东西,第二次console.log(totalQuestions)打印未定义.这是我不理解的东西,因为它发生了.
我希望你能帮助我澄清一下我不理解的概念.谢谢!
我在生产环境中有一个 angular 2 应用程序,它允许您选择个人资料图片。最近,在 safari mobile 上进行测试,特别是针对 IOS 13.3.1 版本(旧)和 IOS 13.4.1(新)版本。我注意到图像根据使用的 safari 浏览器版本旋转显示(我为此构建了一个堆栈闪电战,您可以查看):
IOS 13.3.1 版本(旧)
IOS 13.4.1(新)
当我以纵向模式从 iPhone 拍摄图像并将图像上传到我的应用程序时,它仅针对 IOS 13.3.1 version(older)显示旋转。但是,我检查了每个设备的 EXIF 元信息图像,发现这两个图像在方向属性中具有相同的值:
IOS 13.3.1 版本(旧)
IOS 13.4.1(新)
我的问题是。为什么图像显示会根据 IOS 版本而变化,知道这两种情况下的方向 EXIF 是相同的值 (6)?
这是一个让我担心的主题,因为我已经通过根据 EXIF 方向值旋转图像以使其正确显示来解决这个问题(例如,已经创建了 exif.js 来通过检测 exif 方向标志来处理这种情况),但是这个问题现在随着新版本的IOS再次出现。什么是我可以用来使其随着时间的推移可持续的代码示例?浏览器之间是否没有就管理图像方向达成共识?
这种不合逻辑的行为的解释是什么?
非常感谢!
我试图了解 @JsonIninclude 存在的原因是什么,以便在我的 DTO 中使用它。让我们看这个简单的例子:
代码:
class DemoApplication {
static void main(String[] args) {
SpringApplication.run DemoApplication, args
}
@PostMapping("/")
String greet(@RequestBody Greeting greeting) {
return "Hello ${greeting.name}, with email ${greeting.email}"
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)
class Greeting {
String name
String email
}
Run Code Online (Sandbox Code Playgroud)
B代码:
class DemoApplication {
static void main(String[] args) {
SpringApplication.run DemoApplication, args
}
@PostMapping("/")
String greet(@RequestBody Greeting greeting) {
return "Hello ${greeting.name}, with email ${greeting.email}"
}
}
class Greeting {
String name
String email
}
Run Code Online (Sandbox Code Playgroud)
A代码和B代码之间的唯一区别是 …
我在包含我的前端应用程序 ( https://myapp.com )的 S3 存储桶之前有一个 AWS 云前端。当我https://myapp.com/experts?profession=carpenter浏览我网站的导航元素(在本例中为按钮)时,一切正常。但是,当我尝试通过从浏览器的导航栏中手动输入 url 来访问相同的 url 时,就会出现问题。查询参数消失,只有在导航栏中是没有查询参数的以下网址https://myapp.com.com/experts。
我的问题是,我应该如何配置 AWS cloudfront 以允许我传递查询参数?
非常感谢!
cloud web-applications amazon-s3 amazon-web-services amazon-cloudfront
我需要在角度组件中向图像添加单击事件。我试过:
<img src="../../assets/add.svg" width="18" height="18" (click)="addItem()">
Run Code Online (Sandbox Code Playgroud)
但这不起作用。如果将图像放入按钮中,如下所示:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
Run Code Online (Sandbox Code Playgroud)
它看起来像一个带有图像的按钮,我不想要这个,我希望它看起来像:
<img src="../../assets/add.svg" width="18" height="18">
Run Code Online (Sandbox Code Playgroud)
但这就像:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
Run Code Online (Sandbox Code Playgroud)
我怎么能得到这个,你如何在角度上做到这一点?
我在 angular 4 中有以下 HTML 组件:
<div *ngFor="let item of items; let i = index" class="row">
<div class="col-md-7">
<select
class="form-control form-control-sm"
name="durationTime{{i}}"
required
[(ngModel)]="item.durationTime"
#durationTime{{i}}="ngModel"
[ngClass]="{'is-valid': durationTime{{i}}.valid && durationTime{{i}}.touched, 'is-invalid': durationTime{{i}}.invalid && durationTime{{i}}.touched}">
<option [ngValue]="null" disabled selected>Elige</option>
<option *ngFor="let item of durationTimes" [ngValue]="item"> {{item}} </option>
</select>
<small *ngIf="durationTime{{i}}.invalid && durationTime{{i}}.touched"
class="form-text text-muted-error">
!Debes seleccionar una opción!
</small>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要验证控件,但出现此错误:
Parser Error: Got interpolation ({{}}) where expression was expected at column 25 in [{'is-valid': durationTime{{i}}.valid && durationTime{{i}}.touched, 'is-invalid': durationTime{{i}}.invalid && …Run Code Online (Sandbox Code Playgroud) 我是Spring Boot的新手,我试图在Spring Boot应用程序中使用Spring Security实现身份验证过滤器,但我不明白为什么在tokenService属性中使用@autowired批注时它为null,有人可以向我解释为什么有时候是这样的?以及Java代码中的正确配置是什么(我没有使用xml文件),以便spring tokenService属性不为null。接下来,我将向您展示感兴趣的类别:
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
public static final String TOKEN_PREFIX = "Bearer ";
public static final String HEADER_STRING = "Authorization";
private AuthenticationManager authenticationManager;
@Autowired
private TokenService tokenService;//this is null
public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
@Override
public Authentication attemptAuthentication(HttpServletRequest req,
HttpServletResponse res) throws AuthenticationException {
try {
LoginDto creds = new ObjectMapper()
.readValue(req.getInputStream(), LoginDto.class);
return authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(
creds.getEmail(),
creds.getPassword(),
new ArrayList<>())
);
} catch (IOException e) {
throw new RuntimeException(e);
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular 5应用,我需要知道如何获取最后一个URL并将其放置为指向我的后退按钮的链接。我找到了这个,location.back()但是我需要最后一个URL作为字符串。我如何获得生成的字符串location.back()?
非常感谢!
angular ×7
java ×2
rxjs ×2
spring ×2
spring-boot ×2
spring-mvc ×2
typescript ×2
amazon-s3 ×1
cloud ×1
css ×1
exif ×1
file-upload ×1
html ×1
jackson ×1
javascript ×1
ngfor ×1
observable ×1
routing ×1