如果我有一个返回a的方法List of Dogs,确实Dapper将Where谓词转换为SQLWhere?或者它先得到所有的狗然后过滤列表?
public IList<Dog> GetDogsBy(Func<Dog, bool> predicate)
{
return db.Query<Dog>("SELECT * FROM Dog",null).Where(predicate).ToList();
}
Run Code Online (Sandbox Code Playgroud) 我从Angular 4升级到5并替换Http为HttpClient.我从我的http.post调用中删除了链式地图,现在它返回了一个Observable<Object>,但是在我的组件中它现在正在抱怨concatMap does not exist on type Observable<Object>.这是我正在做的一个例子:
//service
import { HttpClient} from '@angular/common/http';
constructor(private _http: HttpClient) { }
registerDomain()
{
return this._http.post('/api/domain/domain/register', {});
}
//component
registerDomain(caseId,domain) {
return this._domainService.registerDomain(caseId,domain)
.concatMap(operation => this.getOperationDetail(operation.OperationId,this.caseId,domain))
.concatMap(() => this.createRecordSets(domain));
}
Run Code Online (Sandbox Code Playgroud)
我可以看到map和mergeMap Observable<Object>但不是concatMap
我有2个组件,一个父组件和一个子组件。父组件包含以下内容:
<form (ngSubmit)="saveWebsite();" #adminForm="ngForm">
<input type="text" name="WebName" [(ngModel)]="milestone.WebName" class="form-control" required/>
<app-documents [documents]="caseData.CaseWebsiteDocuments" [caseId]="caseId" (fileEvent)="showToast($event)"
(documentsEvent)="documentsEvent($event)"></app-documents>
<button type="submit" class="btn btn-success pull-right" *ngIf="caseId">Save</button>
</form>
Run Code Online (Sandbox Code Playgroud)
子组件包含以下内容:
<input type="text" [(ngModel)]="doc.FriendlyName" name="friendlyName" class="form-control" required/>
Run Code Online (Sandbox Code Playgroud)
如果我将所有输入都放在父组件中,则验证适用于所有组件。我正在尝试检查脏状态。现在,如果我对父级进行更改,则脏状态设置为true,但是如果我对子级进行更改,则脏状态不会更改。如何使验证在模板驱动的嵌套控件中工作?
假设我有一个包含以下 html 的页面:
<input type="button" id="clickme" value="Click Me" />
Run Code Online (Sandbox Code Playgroud)
在同一页面上,我有以下脚本:
<script type="text/javascript">
$('#clickme').click(function(){
console.log("clicked");
});
</script>
Run Code Online (Sandbox Code Playgroud)
上面的内容是否可以内嵌在页面上,还是将其console.log(...)放入库中更好,所以它会是这样的:
<script type="text/javascript src="external.js"></script>
<script type="text/javascript">
$('#clickme').click(function(){
LogToConsole("clicked");
});
</script>
Run Code Online (Sandbox Code Playgroud)
为了更上一层楼,将整个点击功能放在一个外部库中是否更好,这样代码最终会变成这样:'
<script type="text/javascript src="external.js"></script>
<script type="text/javascript">
ClickMe("clicked");
</script>
Run Code Online (Sandbox Code Playgroud)
上面仍然包含内联 javascript 还是我对内联 javascript 的理解不正确,因为似乎无法避免?
如果navigator.language返回en-US,但我只想en因为我不关心locale,是否有更好的方法来做到这一点?Angular 是否为此内置了任何东西,或者我应该在 上拆分-?
如果我浏览到http:\\localhost:4300\fr,我的主页就会加载法语翻译。
我的导航中有 2 个链接(主页、联系我们)。
首页 指向http:\\localhost:4300\fr\home
联系我们 指向http:\\localhost:4300\fr\contact
我还有一个下拉菜单,用户可以在其中选择一种语言,它将返回翻译后的页面。
例如,当我选择西班牙语时,链接会更新为:
http:\\localhost:4300\es\home和http:\\localhost:4300\es\contact,但浏览器 URL 仍保留http:\\localhost:4300\fr。
如何更新浏览器网址?
这是当用户从下拉列表中选择语言时我使用的代码:
translate(langCode, language) {
const hostName = document.location.hostname.replace('www.', '');
this.currentTrans = language;
this.currentTransCode = langCode;
this._caseService.GetCaseData(caseUrl, langCode);
}
Run Code Online (Sandbox Code Playgroud)
this.currentTransCode保存当前语言代码
url 的构造如下http:\\localhost:4300\+this.currentTransCode
我通过aws sdk cognito .net sdk在亚马逊认知中创建用户.当用户登录时,他们会返回3个令牌(IdToken,AccessToken和RefreshToken).IdToken有效期为1小时.目前,当令牌过期时,用户被重定向到登录页面.我想要做的是在收到403返回时发送RefreshToken,但我不确定如何在角度应用程序中执行此操作?
我也假设这是我在客户端而不是在服务器端(.net web api)处理的东西?
我目前在我的路线上有警卫从我的服务中调用以下功能:
loggedIn() {
return tokenNotExpired('token');
}
Run Code Online (Sandbox Code Playgroud)
以下工作,但问题是我必须使用我AccessKey和SecretKey:
refreshToken(){
AWS.config.update({credentials:{accessKeyId:'access_id',secretAccessKey:'secret'}, region:'us-east-2'});
const myCreds = new AWS.CognitoIdentityCredentials({IdentityPoolId:'us-east-2:identity_pool_id},{region:'us-east-2'});
const myConfig = new AWS.Config({credentials: myCreds, region: 'us-east-2'});
const refreshToken = JSON.parse(localStorage.getItem('rToken'));
const cognitoisp = new CognitoIdentityServiceProvider();
const params = {
AuthFlow: 'REFRESH_TOKEN',
ClientId: 'client_id',
UserPoolId: 'user_pool_id',
AuthParameters: {
'REFRESH_TOKEN': refreshToken
}
}
cognitoisp.adminInitiateAuth(params,(err,data)=>{
if(err) console.log(err,err.stack);
else
{
this.token = data.AuthenticationResult.IdToken;
localStorage.setItem('lcToken',JSON.stringify(this.token));
}
})
}
Run Code Online (Sandbox Code Playgroud) 我试图取消订阅ngOnDestroy中的一个observable,但它告诉我它在Observable类型中不存在.
export class AppComponent implements OnInit {
public caseData;
constructor(private _caseService: CaseService,
private _title: Title,
private _metaService: Meta) { }
ngOnInit(): void {
this._caseService.GetCaseData('en', 'English');
this._caseService.caseData$.subscribe(res => { this.caseData = res },
(error) => { console.log(error) });
}
ngOnDestroy() {
this._caseService.caseData$.unsubscribe(); //says it does not exist
}
}
Run Code Online (Sandbox Code Playgroud) 以下将在运行时抛出异常:
string s = string.Format("{0} {1} {2} {3} {4}",1,2,3,4);
Run Code Online (Sandbox Code Playgroud)
但它会成功建立.为什么?