我已成功在我的angularJs(1.x)应用程序中使用Numeral.js库将我的数字设置为不同格式。这就是我使用angular1过滤器的方式:
filter.js
.filter('numeral', function () {
return function (count) {
var numericalFormat = numeral(count).format('0.0a');
return numericalFormat;
};
})
Run Code Online (Sandbox Code Playgroud)
为此,我遵循了Numeral.js的官方文档, 并使用npm进行了安装。我也引用index.html中的nodemodules。
在浏览器中
<script src="node_modules/numeral/numeral.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
但它显示
错误ReferenceError:在NumeralFilter.transform中未定义数字
最初,我尝试使用CDN参考,它可以在浏览器中正常工作。但是,当我在真实设备上安装该应用程序时,出现错误“数字未定义”。
管
import {Pipe,PipeTransform,Injectable} from "@angular/core"
@Pipe({
name:'numeralPipe'
})
@Injectable()
export class NumeralPipe implements PipeTransform{
transform(count:any):any{ //eg: in count has value something like 52456.0
var numericalFormat = numeral(count).format('0.0a');//error here
return numericalFormat; // i have to format it like 52,5k
};
}
Run Code Online (Sandbox Code Playgroud)
是否有任何用于格式化和处理数字的类型脚本库,或者在angular2中有任何方法可以做到这一点?
我想使用pagination的angular-material2.我面临的问题是md-paginator通过服务动态设置值.
我已设法使用静态值创建分页但我不知道如何动态设置它们.
TS
import {Component,ChangeDetectorRef, Input,ViewChild } from '@angular/core';
import {Http, Response, RequestOptions, Headers, Request, RequestMethod} from '@angular/http';
import {MdPaginator,PageEvent} from '@angular/material';
import {DataSource} from '@angular/cdk';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/startWith';
import 'rxjs/add/observable/merge';
import 'rxjs/add/operator/map';
@Component({
selector: 'table-http-example',
styleUrls: ['table-http-example.css'],
templateUrl: 'table-http-example.html',
})
export class TableHttpExample {
displayedColumns = ['dbquery', 'title'];
exampleDatabase: ExampleHttpDatabase | null;
dataSource: ExampleDataSource | null;
pageEvent: PageEvent;
@ViewChild(MdPaginator) paginator: MdPaginator;
constructor(private http: Http) { …Run Code Online (Sandbox Code Playgroud) <mat-tab-group mat-stretch-tabs #tabGroup (focusChange)="tabChanged($event)" [selectedIndex]="0">
<mat-tab label="DATOS EXPEDIENTE">
<div class="example-large-box mat-elevation-z4">
<app-informe-expediente></app-informe-expediente>
</div>
</mat-tab>
<mat-tab label="DATOS ALTERACIÓN">
<div class="example-large-box mat-elevation-z4">
<app-informe-alteracion></app-informe-alteracion>
</div>
</mat-tab>
<mat-tab label="DATOS INMUEBLES">
<div class="example-large-box mat-elevation-z4">
<app-informe-inmuebles></app-informe-inmuebles>
</div>
</mat-tab>
<mat-tab label="FLUJO DE TRAMITACIÓN">
<div class="example-large-box mat-elevation-z4">
<app-informe-tramitacion></app-informe-tramitacion>
</div>
</mat-tab>
<mat-tab label="DOCUMENTOS ASOCIADOS">
<div class="example-large-box mat-elevation-z4">
<app-informe-documentos></app-informe-documentos>
</div>
</mat-tab>
</mat-tab-group>
Run Code Online (Sandbox Code Playgroud)
这mat-tab-group取决于浏览器,因此每次单击提交按钮时它都会触发。我需要知道如何在每次单击提交按钮时获得索引为 0 的第一个选项卡以获得焦点。
我知道它与索引和那些东西有关,但我不知道,我正在使用 MatTabChangeEvent 控制索引。
我正在使用 Mat-Autocomplete,但由于某种原因,它仅在我使用 1 个字段时才有效,当我添加另一个第二个字段时,会发生一些奇怪的事情。
在字段 1 和字段 2 中,我在下拉列表中得到相同的选项,这些选项是仅在我编辑字段 2 时才可用的选项。
甚至有可能有超过 1 个领域,我从来没有看到任何关于这个问题的例子。
场1
<div class="col input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Sender</span>
</div>
<mat-form-field>
<input matInput [matAutocomplete]="auto" type="text" class="form-control" (ngModelChange)="change()" [(ngModel)]="terms[sender]" [ngModelOptions]="{standalone: true}">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let document of documents" [value]="document._source.field.Sender">
<span>{{document._source.field.Sender}}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>
Run Code Online (Sandbox Code Playgroud)
场2
<div class="col input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Receiver</span>
</div>
<mat-form-field>
<input matInput [matAutocomplete]="auto" type="text" class="form-control" (ngModelChange)="change()" [(ngModel)]="terms[receiver]" [ngModelOptions]="{standalone: true}" >
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let document of documents" [value]="document._source.field.Receiver">
<span>{{document._source.field.Receiver}}</span>
</mat-option>
</mat-autocomplete>
</mat-form-field> …Run Code Online (Sandbox Code Playgroud) forms autocomplete angular-material angular mat-autocomplete
我需要测试用户输入是否与列表元素相同,现在我正在这样做:
cars = ("red", "yellow", "blue")
guess = str(input())
if guess == cars[1] or guess == cars[2]:
print("success!")
Run Code Online (Sandbox Code Playgroud)
但我正在处理更大的列表,我的if语句在所有这些检查中都有很多增长,有没有办法引用多个索引,如:
if guess == cars[1] or cars[2]
Run Code Online (Sandbox Code Playgroud)
要么
if guess == cars[1,2,3]
Run Code Online (Sandbox Code Playgroud)
阅读列表文档,我发现不可能引用多个索引,我在上面尝试过,当然会发送语法错误.
我想知道如何在用户登录后显示问候语"欢迎用户,您已登录",并且它应该在5秒内消失.
该消息将在用户成功登录后显示一次,但在同一会话期间连续访问主页时不再显示.因为我在home.html的会话中使用了用户名.
我有下面的代码,我试图从非零数字开始循环"number_panels"和"number_turbines".
更具体地说,我正在尝试使用500个面板间隔的3000到4000"number_panels"以及具有一个涡轮间隔的5到8"number_turbines",即
number_of_days = 2;
for number_panels = 3000:500:4000 % range of PV panel units examined
for number_turbines = 5:8 % range of wind turbine units examined
for h=1:24 %# hours
for d = 1:number_of_days %# which day
n = h + 24*(d-1);
% hourly_deficit_1(...,..., h, d)= Demand(n)-(PV_supply(n)... %
hourly_deficit(number_panels + 1, number_turbines + 1, h,d) = hourly_annual_demand(n) - (hourly_annual_PV(n)*number_panels) - (hourly_annual_WT(n)*number_turbines);% hourly power deficit (RES supply with demand)
if hourly_deficit(number_panels + 1, number_turbines + 1, h,d)< 0 % zero …Run Code Online (Sandbox Code Playgroud) 如何使用eclipse将代码提交到GitHub Server中?
当我运行此命令时
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
它显示以下错误
错误:访问https://github.com/something/something时,请求的URL返回错误:403
如何将Facebook登录集成到iOS应用程序中,适用于所有版本?
我没有一个完整的解决方案,几个小时就一直在搜索Google和GitHub.我还阅读了Facebook上的所有文档,并剖析了ios-facebook示例代码.我有一个> = iOS6的工作版本,但是下面的任何东西都会崩溃(ACAccountStore不存在).目前我正在使用名为LBFacebook的库来登录.唯一的缺点是,它不适用于iOS5.
我把头发拉了出来.FacebookSDK每隔几周就会发生变化.让这一切工作一劳永逸是神奇的.
facebook facebook-graph-api ios acaccountstore facebook-sdk-3.0
angular ×4
angular-pipe ×1
autocomplete ×1
brute-force ×1
c++ ×1
django ×1
eclipse ×1
facebook ×1
for-loop ×1
forms ×1
github ×1
ionic2 ×1
ios ×1
java ×1
mat-tab ×1
matlab ×1
numeral.js ×1
pagination ×1
php ×1
python ×1
sms ×1
tabs ×1