我正在使用MEAN.js样板,你可以在这里找到整个代码.
我尝试在从列表中选择其中一篇文章后向页面添加2个新选项卡.为此,我决定为Angular.js使用UI-Router和UI-Bootstrap.2个选项卡无法正常工作,我可以在它们之间切换并正确查看其内容,但偶尔当我返回并选择文章列表菜单项时,我得到一个带有2个选项卡的空白页面,而不是其他任何内容.
以下是对view-article.client.view.html文件的更改,包括2个新选项卡(之前的内容已复制到包含新选项卡的部分的2个文件中):
<div ng-controller="ArticlesController">
<tabset>
<tab
ng-repeat="t in tabs"
heading="{{t.heading}}"
select="go(t.route)"
active="t.active">
</tab>
</tabset>
<div ui-view></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经在文章控制器中插入了以下几行代码:
$scope.tabs = [
{ heading: 'SubA', route:'viewArticle.SubA', active:false },
{ heading: 'SubB', route:'viewArticle.SubB', active:false }
];
$scope.go = function(route){
$state.go(route);
};
$scope.active = function(route){
return $state.is(route);
};
$scope.$on('$stateChangeSuccess', function() {
$scope.tabs.forEach(function(tab) {
tab.active = $scope.active(tab.route);
});
});
Run Code Online (Sandbox Code Playgroud)
这是route.js
'use strict'
angular.module('articles').config(['$stateProvider',
function($stateProvider) {
$stateProvider.
state('listArticles', {
url: '/articles',
templateUrl: 'modules/articles/views/list-articles.client.view.html'
}).
state('createArticle', {
url: '/articles/create',
templateUrl: 'modules/articles/views/create-article.client.view.html'
}).
state('viewArticle', …Run Code Online (Sandbox Code Playgroud) 我可以下载图片和pdf,但我不能下载文档文件(.doc .pptx .odt ...)
当下载文档(.doc .pptx .odt ...)作为 .ZIP 仅 XML 文件下载时。我可以做什么?
我正在使用:填写上传文件文档
upload: function (req, res) {
req
.file('avatar')
.upload({
maxBytes: 10000000
}, function whenDone(err, uploadedFiles) {
if (err) {
return res.negotiate(err);
}
// Generate a unique URL where the avatar can be downloaded.
avatarUrl = require('util').format('%s/user/avatar/%s', sails.getBaseUrl(), req.session.User.id_user),
// Grab the first file and use it's `fd` (file descriptor)
avatarFd = uploadedFiles[0].fd
var SkipperDisk = require('skipper-disk');
var fileAdapter = SkipperDisk(/* optional opts */);
// Stream the file …Run Code Online (Sandbox Code Playgroud) 在我的 Android 反应本机应用程序中,我将 jpg 文件从缓存文件夹移动到 RNFS.DocumentDirectoryPath,我在其中创建了一个“图像”文件夹。我无法渲染这些图像:
在反应类中:
state = {source:null}
async componentDidMount() {
async loadFile ( path ){
await this.setState({source:{uri:path}})
}
const path = RNFS.DocumentDirectoryPath+'/images/d88b102c-d4c6-4dc1-9a4c-f2a0e599ddbf.jpg'
await RNFS.exists(path).then( exists => {
if(exists){
this.loadFile(path);
}
}
renderItem = ({ item }) => (
<View key={item.Id} >
<View>
<TouchableOpacity onPress={() => this.onPressItem(item)}>
<Text>{item.cardName}</Text>
<Image
source={this.state.source}
style={{ width:'auto', height: 55 }}
/>
</TouchableOpacity>
</View>
</View>
);
Run Code Online (Sandbox Code Playgroud)
如果我将图像转换为 base64,图像就会存在,它会正确渲染。
什么是最好的解决方案,以查找只有一条记录的 Waterline - Sails 查询来搜索给定日期中 room2 的最后插入价格?
ID PRICE START STOP ROOM createdAt updatedAt
-------------------------------------------------------------------------
85 750.00 2016-01-01 2017-12-31 room1 2016-02-25 10:09:47 2016-02-25 10:09:47
86 590.00 2016-01-01 2017-12-31 room2 2016-02-25 10:09:55 2016-02-25 10:09:55
90 410.00 2016-02-25 2016-02-27 room2 2016-02-25 16:46:08 2016-02-25 16:46:08
91 310.00 2016-01-26 2016-04-28 room2 2016-02-26 09:35:26 2016-02-26 09:35:26
Run Code Online (Sandbox Code Playgroud)
做这些我得到错误的结果:
var where = {"start":{"<=":"2016-02-25T23:00:00.000Z"},"end":{">=":"2016-02-25T23:00:00.000Z"},"room":"room2"}
PriceHistory.find(where).max('createdAt').exec(function(err, prices){
res.json(prices);
});
Run Code Online (Sandbox Code Playgroud) sails.js ×2
angularjs ×1
javascript ×1
meanjs ×1
node.js ×1
npm ×1
react-native ×1
waterline ×1