我想创建一个接收 Class 参数的注释,JAVA 中的示例应该是
@Retention(RUNTIME)
public @interface CustomAnnotation {
Class<Comparable<?>> comparator();
}
Run Code Online (Sandbox Code Playgroud)
我想在 Kotlin 中应该是:
@Retention(AnnotationRetention.RUNTIME)
annotation class CustomAnnotation(
val comparator: Class<Comparable<*>>
)
Run Code Online (Sandbox Code Playgroud)
但是在 Kotlin 中收到错误消息Invalid type of annotation member,那么在 Kotlin 中应该如何等效地接受类作为参数呢?
我有一个带模态的角度项目,我想在关闭时发送多个(两个)参数,问题是它给出了未定义的第二个参数,我的代码是以下
/*Modal controller*/
angular.module('assetModule')
.controller('assetModalLocationCtrl', ['locationRESTService','$modalInstance','$scope', '$q', assetModalLocationCtrl]);
function assetModalLocationCtrl (locationRESTService, $modalInstance, $scope, $q) {
this.ok = function () {
$scope.info.selected = selected ($scope.data.locations)
$modalInstance.close($scope.data.locations, $scope.info.selected);
};
}
/*Controller that invoke the modal*/
this.modalLocation = function modalLocation (size){
var modalInstance = $modal.open({
animation: this.animationsEnabled,
templateUrl: 'views/asset/assetLocationModal.html',
controller: 'assetModalLocationCtrl',
controllerAs: 'modalLocation',
size: size,
});
modalInstance.result.then(function (selectedItem, locationList) {
console.log(selectedItem);
console.log(locationList);
}, function () {
console.log('Modal dismissed at: ' + new Date());
});
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用Express 4的NodeJS API.我使用sequelize连接到数据库,我多次调用一个查询.我想将结果累积到一个数组中.问题是res.send不要等待循环结束才能发送答案.
我的代码
router.post('/payrollReport/', function(req, res, next) {
var usersRecord = [];
models.user.findAll(
).then(function(users) {
for (var i = 0; i < users.length; i++) {
models.sequelize.query('SELECT forms.name, COUNT(form_submits.form_id) ' +
'FROM form_submits ' +
'LEFT JOIN forms ON forms.form_id = form_submits.form_id ' +
'WHERE form_submits.user_id = ' + users[i].user_id +
'AND date("form_submits"."createdAt") >=' + req.body.begin +
'AND date("form_submits"."createdAt") <=' + req.body.end +
" GROUP BY forms.name")
.then(function(results){
usersRecord.push(results[0]);
console.log(usersRecord);
});
};
}).catch(function(error) {
res.status(500).send(error);
});
res.send(usersRecord);
}); …Run Code Online (Sandbox Code Playgroud) 您好我尝试使用堆栈为yesod创建一个新的proyect,按照快速入门教程; 创建脚手架我使用命令:
stack new my-project yesod-postgres && cd my-project
Run Code Online (Sandbox Code Playgroud)
但是当跑步时stack exec -- yesod devel得到:
cabal: At least the following dependencies are missing:
classy-prelude >=0.10.2,
classy-prelude-conduit >=0.10.2,
classy-prelude-yesod >=0.10.2,
data-default -any,
hjsmin >=0.1 && <0.3,
monad-logger ==0.3.*,
persistent >=2.0 && <2.6,
persistent-postgresql >=2.1.1 && <2.6,
persistent-template >=2.0 && <2.6,
safe -any,
yesod >=1.4.3 && <1.5,
yesod-auth >=1.4.0 && <1.5,
yesod-core >=1.4.17 && <1.5,
yesod-form >=1.4.0 && <1.5,
yesod-static >=1.4.0.3 && <1.6
Run Code Online (Sandbox Code Playgroud)
我尝试使用该命令stack exec -- cabal install …
我有以下组件加载文件并将其内容绑定为字符串
export class NgCsvComponent {
@Input() csv: any;
@Output() csvChange: any = new EventEmitter();
public localCsv : any = '';
constructor() { }
changeListener($event): void {
this.readFile($event.target);
}
readFile (inputValue : any) : void {
let reader = new FileReader (),
file : File = inputValue.files[0];
reader.readAsText(file);
reader.onload = this.onLoadCallback;
}
onLoadCallback (event) {
this.csvChange.emit(event.target["result"]);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是this.csvChange 内部未定义,onLoadCallback所以如何将结果传递给组件中的某个变量?
我正在搜索其他类似的问题,但从未在onloadCallback函数之外得到结果
我有以下代码
newtype MyList a = MyList { getList :: [a] } deriving Show
instance Functor MyList where
fmap f x = MyList (fmap f (getList x))
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
它可以指代"Prelude.fmap"从compile.hs"前奏"输入:1:6:1:1或1"Main.fmap",(和最初在"GHC.Base"中定义)在compile.hs定义
如果我明白的话.如果我为新类型创建的新实例会影响List []类型的现有实例.但为什么会发生呢?我认为newtype的目标是为同一类型创建一个不同的实例
haskell ×2
angular ×1
angularjs ×1
annotations ×1
asynchronous ×1
express ×1
filereader ×1
javascript ×1
kotlin ×1
node.js ×1
typescript ×1
yesod ×1