当我使用模型驱动的形式,如:
@Component({
selector: 'my-app',
template: `
<p>
<label>First Name:</label>
<input type="text" [ngModel]="user.firstName" required>
</p>
`,
providers: [myService]
})
Run Code Online (Sandbox Code Playgroud)
当我使用模板驱动形式时,如:
@Component({
selector: 'my-app',
template: `
<p>
<label>First Name:</label>
<input type="text" formControlName="firstName">
</p>
`,
providers: [myService]
})
Run Code Online (Sandbox Code Playgroud)
我认为上面两件事都有相同的功能.所以,在开始新项目的时候,我觉得哪个更好?
我正在使用 http 拦截器来拦截应用程序中的每个 http 请求。但我发现循环依赖: $http <- APIInterceptor <- $http <- $templateRequest <- $compile
这是我的服务代码:
mPosServices.factory('mosServiceFactory', function ($http, $rootScope, $cookies, $q) {
return{
refresh_token: function () {
var refreshToken = $http({
method: "get",
url: "myservice/oauth/token?grant_type=refresh_token&client_id=restapp&client_secret=restapp&refresh_token=" + $cookies.get('refresh_token'),
})
return refreshToken;
}
});
mPosServices.service('APIInterceptor', ['mosServiceFactory','$cookies',function (mosServiceFactory,$cookies) {
var service = this;
service.request = function (config) {
if (!$cookies.get('access_token')) { //if access_token cookie does not exist
mosServiceFactory.refresh_token().then(function (response) {
var date = new Date();
date.setTime(date.getTime() + (response.data.expiresIn * 1000));
$cookies.remove('access_token');
$cookies.put('access_token', …Run Code Online (Sandbox Code Playgroud) 我正在制作一个网页并且我有很多文本,所以我制作了一个文本框,您可以使用Overflow: auto. 我的问题是我怎样才能更清楚地说明您可以滚动查看更多内容?目前,如果你不知道有更多文本,你可能不会滚动,所以我想添加一个小箭头作为滚动条,我可以只用 CSS 和 HTML 来做到这一点吗?
.container {
width: auto;
left: 25%;
height: 60%;
overflow: auto;
}
.text-box {
position: absolute;
top: 20%;
width: 50%;
overflow: auto;
height: 70%;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="text-box">
<h2 class="">I servizi per l'editoria scolastica</h2>
<p>
<h4>Progettazione e supporto alla progettazione di testi scolastici e universitari:</h4>
<ul>
<li>elaborazione di progetti editoriali e collane
<li>consulenza e supervisione didattica
<li>stesura apparati operativi
<li>supporto e consulenza agli autori</ul>
<h4>Progettazione grafica</h4>
<ul>Analisi progetto editoriale e confronto …Run Code Online (Sandbox Code Playgroud)可能是我误会了angular的changeDetection策略。
这是说明:
onPush变更检测策略注册。loading在进行HTTP服务调用时使用文本,然后在ngIf使用原始变量完成使用后删除文本this.loading=true/false现在我的问题是,当App最初加载时,我可以loading...在S2小部件上看到文本,然后填充数据。
但是,当我单击notify siblingS1中的按钮时,它确实触发了服务调用,但是在http处理过程中,我看不到loading...文本。
这是S1的代码:
import { Component, OnInit } from '@angular/core';
import { MessagingService } from '../messaging.service';
@Component({
selector: 'app-parent',
templateUrl: './parent.component.html',
styleUrls: ['./parent.component.css']
})
export class ParentComponent implements OnInit {
constructor(private _sendMessage: MessagingService) { }
ngOnInit() {
}
notifyChild() {
this._sendMessage.notifySibling();
}
}
Run Code Online (Sandbox Code Playgroud)
这是S2的代码:
import { Component, OnInit,ChangeDetectionStrategy ,ChangeDetectorRef} from '@angular/core';
import { MessagingService } from '../messaging.service';
import …Run Code Online (Sandbox Code Playgroud)