小编Val*_*ert的帖子

在没有ReactiveForm的情况下使用Angular Material mat-autocomplete

我尝试使用<mat-autocomplete>Angular Material(不是AngularJS)而不使用反应形式.但他们所有的例子都使用反应形式......

我尝试做的事情:
1.当输入内容时mat-input,进行Ajax调用以检索用户列表
2.显示自动完成中的用户列表(显示用户名),但将用户存储为模型
3当模型改变时,调用我选择的函数

现在我做那些疯狂的事情(我说疯了似乎很多).

<mat-form-field fxLayout>
  <input type="text"
             matInput fxFlex="100"
             [(ngModel)]="listFilterValue"
             (keyup)="memberInputChanged(input.value)"
             (change)="memberChanged()"
             *ngIf="isAutocompleteNeeded()"
             #input
             [matAutocomplete]="auto">
</mat-form-field>

<mat-autocomplete #auto="matAutocomplete" [displayWith]="getMemberAsStr">
       <mat-option *ngFor="let member of members | async" [value]="member">
          {{ getMemberAsStr(member) }}
       </mat-option>
</mat-autocomplete>
Run Code Online (Sandbox Code Playgroud)

现在,只有console.log在我的JS中才能看到所谓的内容,具有什么价值,所以我不在这里分享它.我使用正确的属性,正确的逻辑吗?

(members我的组件中的属性是Rxjs BehaviourSubject)

我现在所做的事情不起作用,因为listFilterValue它从未被设定为任何东西.

谢谢你的帮助

angular-material2 angular mat-autocomplete

10
推荐指数
1
解决办法
1万
查看次数

Javascript 日期到 ISO 格式的字符串(带时区)

我经常使用 MomentJS,但我正在开始一个新项目,但我不想包含这个库,因为我只使用过几次日期。

所以我想做的是获取日期的字符串表示形式,采用类似 ISO 的格式('YYYY-MM-DDZHH:mm:ss' 或 'YYYY-MM-DD HH:mm:ss')。我不希望它在 UTC 中:我希望在给定的时区中(我可以以编程方式提供)。

例如,现在的表示为“2017-04-11 11:20:00”(法国时区 - 相当于“2017-04-11 09:22:00Z”。)

我想要原生 JavaScript。我一直在玩toLocaleString没有成功。

谢谢

[编辑] 在完美的世界中,我正在寻找一个函数,它采用日期格式、时区并返回我想要的字符串。喜欢:

function magicDateFormatter(format, tz) {
  /* ... */
}

var now = new Date();
console.log(magicDateFormatter('YYYY-MM-DD HH:mm:ss', 'Europe/Paris'));
// print "2017-04-11 11:20:00"
Run Code Online (Sandbox Code Playgroud)

javascript timezone date

8
推荐指数
2
解决办法
1万
查看次数

jQuery scrollTop值是什么意思?

我正在使用scrollTop方法实现一些jquery代码来实现无限滚动(请不要建议jQuery插件,我知道它们存在)并且我不太明白这个值意味着什么.

鉴于这个小提琴:https://jsfiddle.net/ve8s5fdx/

<div id="outter">
  <div class="inner"></div>
  <div class="inner"></div>
</div>
<div id="scroll"></div>
Run Code Online (Sandbox Code Playgroud)
#outter {
  height: 100px;
  width: 100%;
  overflow-y:auto;
}

.inner {
  height: 150px;
  width: 50%;
  border: dashed black 2px;
  background-color: grey;
}
Run Code Online (Sandbox Code Playgroud)

当滚动条位于元素的最顶部时,值为0是有意义的,但是当它位于底部时为什么是"208"?该#outterDIV是100像素高,其含量比为300px多一点.

html javascript css jquery

5
推荐指数
1
解决办法
1006
查看次数

Angular-以字符串形式获取格式,用于根据语言环境显示日期

如何获取Angular用于显示日期的字符串形式的格式?我用的是date管道设置后,LOCALE_ID在我的app.module

现在,我想检索“ dd / mm / yyyy”字符串,以放入我的输入占位符。

基本上,这里描述的只是Angular。

谢谢

[编辑]

为了使它更明确,我没有在寻找一种格式化日期的方法,这种方法已经完成了(使用本机date管道)。我想要代表此管道正在使用的格式的字符串。

因为我希望我的日期选择器占位符像

“日期(格式:XXXXXX)”

我希望“ XXXXXX”部分正确(例如,法语为“ jj / mm / aaaa”,英语为“ mm / dd / yyyy”)

angular-date-format angular

5
推荐指数
1
解决办法
2197
查看次数

使用 oauth2client 创建 google api 凭据(来自具有范围和委托帐户的服务帐户)

要访问 GMail API(和拟人化调用),我使用服务帐户(从 Google Cloud Platform 创建)。我的 json 文件看起来像这样

{
"type": "service_account",
"project_id": "[PROJECT-ID]",
"private_key_id": "[KEY-ID]"
"private_key": "-----BEGIN PRIVATE KEY-----\n[PRIVATE-KEY]\n-----END PRIVATE KEY-----\n",
"client_email": "[SERVICE-ACCOUNT-EMAIL]",
"client_id": "[CLIENT-ID]",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[SERVICE-ACCOUNT-EMAIL]"
}
Run Code Online (Sandbox Code Playgroud)

我还使用oauth2client库来简化操作,但我找不到创建凭据然后指定范围和委托帐户的方法。

我试过

from oauth2client import service_account

self._credentials = service_account.ServiceAccountCredentials.from_json(SERVICE_ACCOUNT_JSON_CONTENT)
self._credentials = self._credentials.create_scoped([u'https://www.googleapis.com/auth/gmail.send'])
self._credentials = self._credentials.create_delegated(MY_USER)
        self._client = discovery.build(u'gmail', u'v1', credentials=self._credentials)
Run Code Online (Sandbox Code Playgroud)

但我收到错误,因为它需要 PKCS-8 密钥。

我怎样才能做到这一点 ?(如果有帮助的话,我的代码在 App Engine Flex 上运行)

谢谢

oauth2client google-oauth service-accounts app-engine-flexible

5
推荐指数
1
解决办法
2万
查看次数

Angular 2 @HostListener未捕获keyup事件

我有一个应该捕获键入事件的Google地图。我的组件是google maps div的父级。它可以在Chrome上正常运行,不能在Firefox或IE(未经测试的wtith Edge)上运行。

我的组件:

@Component({
  selector: 'dashboard',
  templateUrl: 'dashboard.component.html',
  styleUrls:  ['dashboard.component.css'],
  host: {
    '[attr.tabindex]': '-1'
  },
  providers: []
})
export class DashboardComponent implements OnInit{

  /* some functions and other stuff here 
  * ...
  */

  @HostListener('keyup', ['$event']) keyup(e) {
    console.log('This will be called with Chrome, not with the others.');
  }
};
Run Code Online (Sandbox Code Playgroud)

你经历过同样的经历吗?(如果需要更多信息,请告诉我)。谢谢

[edit]
我尝试keyup通过使用ElementRef并将事件处理程序设置为的onkeyup属性来捕获事件,但是elementRef.nativeElement没有运气

javascript angular

2
推荐指数
2
解决办法
4064
查看次数

达到父级的最大高度时可滚动的子级

My problem is quite similar to this one but the difference I can see is that my parent div (#container) have a min-height and a max-height (no height as it should grow with its content), but the scrollable div (#dynamic-part) does not know its height nor max-height either. It should be scrollable when its parent has reached its max-height.

Is that something possible with pure CSS ?

HTML

<div id="container">
  <div id="fixed-part">
  This will always …
Run Code Online (Sandbox Code Playgroud)

html css css3

2
推荐指数
1
解决办法
646
查看次数