我有一个Angular 2组件我试图进行测试,但是我遇到了麻烦,因为数据是在ngOnInit函数中设置的,所以在单元测试中不能立即使用.
用户view.component.ts:
import {Component, OnInit} from 'angular2/core';
import {RouteParams} from 'angular2/router';
import {User} from './user';
import {UserService} from './user.service';
@Component({
selector: 'user-view',
templateUrl: './components/users/view.html'
})
export class UserViewComponent implements OnInit {
public user: User;
constructor(
private _routeParams: RouteParams,
private _userService: UserService
) {}
ngOnInit() {
const id: number = parseInt(this._routeParams.get('id'));
this._userService
.getUser(id)
.then(user => {
console.info(user);
this.user = user;
});
}
}
Run Code Online (Sandbox Code Playgroud)
user.service.ts:
import {Injectable} from 'angular2/core';
// mock-users is a static JS array
import {users} from …Run Code Online (Sandbox Code Playgroud) 我试图通过Sails的JSON发送经过身份验证的用户的所有权限.
我当前的代码,用于查找单个模型类型的权限:
hasPermission: function hasPermission(req, res) {
var permitted = PermissionService.isAllowedToPerformAction({
method: req.param('method'),
model: sails.models[req.param('model')],
user: req.user
});
return res.json(200, { permitted: permitted });
}
Run Code Online (Sandbox Code Playgroud)
此代码不能像isAllowedToPerformAction单个模型实例那样工作.有没有办法返回一个会计所有权限的JSON文件?
我有一个以前工作的组件(没有为描述设置HTML标签),现在尝试让HTML格式化后,它将无法保存.
com_lot \意见\大量\ TMPL\form.php的:
<?php defined('_JEXEC') or die('Restricted access');
$document =& JFactory::getDocument();
$document->addScript('includes/js/joomla.javascript.js');
require_once(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'helpers' .DS. 'browser.php');
?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
<?php
$editor =& JFactory::getEditor();
echo $editor->save( 'description' );
?>
submitform(pressbutton);
}
</script>
...
<tr>
<td width="100" align="right" class="key">
<label for="description">
<?php echo JText::_( 'Description' ); ?>:
</label>
</td>
<td>
<?php
$editor =& …Run Code Online (Sandbox Code Playgroud) 我正在尝试从电子表格构建日历,然后与域内的适当人员共享它们。我将其作为附加到电子表格的脚本来执行。
到目前为止,我可以读取正确的单元格并使用事件构建日历,但我遇到的问题是弄清楚如何与正确的人共享特定的日历。
我四处搜索并找到了相同的通用代码来手动请求网页允许访问,但我尝试使用但没有成功。我是否错过了其他人都认为你已经完成的步骤?我所做的只是在电子表格上编写一个脚本,是否有一些设置可以让它工作?
如果通过脚本无法实现,那么处理这种事情的最佳方法是什么?使用 PHP 和 cron 作业会更好吗?
我当前共享日历的代码是:
function onEdit() {
calendarSharing('nic@xyz.com', 'boris@xyz.com');
};
function calendarSharing(user1,user2){
var scope = 'https://www.google.com/calendar/feeds/';
var fetchArgs = googleOAuth_('calenders', scope);
var rawXml= "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'>"+
"<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/>"+
"<gAcl:scope type='user' value='"+user2+"'></gAcl:scope>"+
"<gAcl:role value='http://schemas.google.com/gCal/2005#owner'> </gAcl:role></entry>"
fetchArgs.method = 'POST';
fetchArgs.payload = rawXml
fetchArgs.contentType = 'application/atom+xml';
try{
var url='https://www.google.com/calendar/feeds/'+user1+'/acl/full'
var urlFetch=UrlFetchApp.fetch(url,fetchArgs) //Giving Permission To personal account as a owner
}
catch(err){
var err1=err.toString()
var ex='Exception: Request failed for returned code 302'
if(ex==err1.split('.')[0]){
var tempCalenderUrl=[]
tempCalenderUrl.id = err1.split('<A …Run Code Online (Sandbox Code Playgroud)