我意识到,这个问题是重复但前一次没有提供适当的答案时刻包已经安装
1.安装包裹
npm install moment-timezone --save
在node_modules目录中
|
| --moment
| --moment-timezone
目录存在
2. Index.html包含脚本
<script src="node_modules/moment-timezone/moment-timezone.js"></script>
Run Code Online (Sandbox Code Playgroud)
System.config.js
var map = {
'moment': 'node_modules/moment',
'momentzone': 'node_modules/moment-timezone'
};
var packages = {
'moment': { defaultExtension: 'js' },
'momentzone': { defaultExtension: 'js' }
};
Run Code Online (Sandbox Code Playgroud)
3.Inside component.ts文件
import * as moment from 'moment/moment';
export class TimeComponent implements OnInit{
ngOninit(){
console.log(moment("2014-06-01T12:00:00Z").tz('America/Los_Angeles').format('ha z'));
}
}
Run Code Online (Sandbox Code Playgroud)
应该导入什么来防止错误 属性tz在"Moment"类型上不存在
Newb to Angular 2.
如何在我的应用中加入Google字体.应用结构是
客户端
| --app.ts
| --main.ts
| --index.html
IndexFile.html
<head></head>
<body style="font-family: 'Montserrat', sans-serif;">
<div class="container-fluid">
<app-start>Loading...</app-start>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
头标记中包含的链接
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)
但是没有发生任何影响,还在客户端文件夹(font.js)中创建了一个JS文件并插入了代码
Meteor.startup(function() {
WebFontConfig = {
google: { families: [ 'Montserrat::latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
})
Run Code Online (Sandbox Code Playgroud)
但没有效果.
在Angular 2 + Meteor应用程序中包含此字体的正确方法
在Angular App
Angular 2应用程序中实现Child Routes的演示应用程序,
显示错误
Error: Uncaught (in promise): Error: Cannot match any routes: 'movie-home'
zone.js:461 Unhandled Promise rejection: Cannot match any routes: 'movie-home' ; Zone: angular ; Task: Promise.then ; Value: Error: Cannot match any routes: 'movie-home'(…)
Run Code Online (Sandbox Code Playgroud)
如果我不从文件movie.routes.ts添加这些代码行,应用程序工作正常
{
path:'movie-home',
component:HomeComponent,
//Remove this block of code- Start
children:[
{path : 'animation' , component:AnimationComponent},
{path : 'action' , component:ActionComponent}
]**
//Remove this block of code.- End
}
Run Code Online (Sandbox Code Playgroud)
我已将代码推送到GITHUB
克隆 - https://github.com/Sandeep3005/Angular101.git
查看 - https://github.com/Sandeep3005/Angular101
文件结构是
app
| …
尝试使用身份api学习我的chrome扩展的oauth.
我已将代码上传到
https://github.com/Sandeep3005/learn-oauth-extension
问题:
当后台文件运行时 - 它会打开一个带有Gmail登录页面的新选项卡.但即使我提供了正确的凭据,登录页面也会一次又一次出现,我必须强制退出Chrome.
Stack Overflow Solution提供的解决方案 - 提及当https://console.developers.google.com中的 app-ID中chrome中的app-ID不同时会发生这种情况.
但是我检查并重新检查了它.应用程序ID的两个值都是准确的.
任何人都可以指导我这个.
的manifest.json
{
"manifest_version": 2,
"name": "outh-test-2",
"short_name": "outh-test-2",
"description": "Description for outh-test-2",
"version": "1.0",
"background": { "scripts": [ "background.js" ], "persistent": true },
"content_scripts": [
{
"run_at": "document_end",
"matches": [
"https://www.dominos.co.in/",
"https://en.wikipedia.org/*"
],
"js": [ "content.js" ]
}
],
"permissions": [
"identity"
],
"oauth2": {
"client_id": "574710815026-blt94u58ie7jqqanuc73b49mdaqrp9j4.apps.googleusercontent.com",
"scopes": [
"http://www.googleapis.com/auth/drive"
]
},
"key":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmRBFelCyG27kHcy38C/bZXggBPDV3JyKnsunJDfHotUG9QQI6Z+KzoeEdCKK/GvQe7AGTNkkr3FUATGmR1b5MbjzTx90qzg6xsrXSU7mqBgJwYPny+PW46pGRwMSz4FEcLO1vUKD9kIhpSzi+0RJv1IwDx6/SNeQzOxXR5B7dWXTKtbiD9f9Rd5yj9Qfy1Q76iIc8P6afpO1DgT960+yZV4+12tCoC+GZILvK3GBwC0vhkeVsIMWaNkIIzC/0PcbLis2HrfZz6iHcetcv4aY6MAIfQWBxaFbDiXXIhXSvi9zO00w/mc9hLxls4fcivXZdEowgEu0UV4+EJuzL35s2wIDAQAB"
}
Run Code Online (Sandbox Code Playgroud)
background.js
console.log('Welcome to background Page');
console.log('chrome Identity = …
Run Code Online (Sandbox Code Playgroud) 在Angular 2中,创建一个简单的应用程序但是当在选择列表的情况下使用DOM控件附加formBuilder时,第一个选项变为空白 - 即使我在formBuilder中提供了一些初始值,该值不是来自DOM元素
在FomBuilder之前
选择列表
Genral
LDAP
在FomBuilder之后
选择List
No选项最初出现
Genral
LDAP
File 1 - form.component.ts
import { Component } from '@angular/core';
import { FormBuilder, Validators, REACTIVE_FORM_DIRECTIVES, FormGroup, FormControl } from '@angular/forms';
@Component({
moduleId : module.id,
selector : 'login',
templateUrl : 'login.component.html',
directives : [ REACTIVE_FORM_DIRECTIVES ],
})
export class LoginComponent{
loginForm : FormGroup;
constructor(private _router:Router,private _fb:FormBuilder){
this.loginForm = _fb.group({
'username' : ['aa',[Validators.required]],
'password' : ['',[Validators.required]],
'type' : ['']
})
}
}
loginUser(){
console.log("Form is = ",this.loginForm.controls);
}
Run Code Online (Sandbox Code Playgroud)
文件2 …
在我的应用程序中,我有不同的 CSS 文件,如 fire.css、lake.css,每个文件都为完整的应用程序提供了不同的外观。
目前,我只用 1 个文件 main.css 实现并将这个文件添加到
index.html
<link rel="stylesheet" href="resources/styles/main.css">
<link rel="stylesheet" href="resources/styles/themes.css">
<link rel="stylesheet" href="resources/styles/common.css">
<link rel="stylesheet" href="resources/styles/plugins.css">
Run Code Online (Sandbox Code Playgroud)
现在我想在用户从下拉列表中选择时动态更改它。
我的想法:将所有 css 文件复制到 app 文件夹并在那里添加主题。
文件夹结构是
app
|-----app.component.ts
|-----app.routes.ts
|-----main.css
|-----lake.css
|-----登录
|- ----其他组件...
我在app.components.ts App 组件中添加了 css 到 styleUrls现在是
import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
selector: 'workshop-app',
template: `
<body>
<router-outlet></router-outlet>
</body>
`,
directives : [ ROUTER_DIRECTIVES ],
styleUrls : ['app/lake.css']
})
export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)
Lake.css …
css stylesheet angular2-directives angular2-template angular
使用 DraftJS 和 Meteor Js 应用程序所涉及的代码任务 - 进行实时预览,其中来自 DraftJS 的文本将被保存到 DB 并从 DB 显示在另一个组件上。
但问题是一旦数据来自数据库,我尝试编辑 DraftJS 光标移动到开头。
代码是
import {Editor, EditorState, ContentState} from 'draft-js';
import React, { Component } from 'react';
import { TestDB } from '../api/yaml-component.js';
import { createContainer } from 'meteor/react-meteor-data';
import PropTypes from 'prop-types';
class EditorComponent extends Component {
constructor(props) {
super(props);
this.state = {
editorState : EditorState.createEmpty(),
};
}
componentWillReceiveProps(nextProps) {
console.log('Receiving Props');
if (!nextProps) return;
console.log(nextProps);
let j = nextProps.testDB[0];
let c = ContentState.createFromText(j.text);
this.setState({ …
Run Code Online (Sandbox Code Playgroud) 我正在学习制作gmail插件.但我仍然坚持如何访问使用插件的用户的电子邮件地址值.
阅读之后,我知道我将需要此权限 https://www.googleapis.com/auth/userinfo.email
但是,当用户在Gmail中打开插件时,如何实际获取电子邮件地址
请有人帮我解决这个问题
angular ×5
javascript ×3
meteor ×2
typescript ×2
angularjs ×1
css ×1
draftjs ×1
fonts ×1
gmail-addons ×1
gmail-api ×1
node.js ×1
oauth ×1
reactjs ×1
stylesheet ×1