目前正在开发Angular JS电视应用程序.该应用程序从api调用中获取数据.我试图从结果数组中获取图像.
这是mainController.js的代码
app.controller("mainController", function($scope, $http){
$scope.apiKey = "b3e2e6f87d3aeec3075668a1bd4a78e2";
$scope.init = function(){
//api call requires format, apiKey, date, and days
var today = new Date();
//format apiDate according to the api specifications
var apiDate = today.getFullYear() + ("0" + (today.getMonth()+1)) + today.getDate();
$scope.results = [];
console.log(apiDate);
$http.jsonp('http://api.trakt.tv/calendar/premieres.json/' + $scope.apiKey + '/' + apiDate + '/' + 30 + '/?callback=JSON_CALLBACK').success(function (data){
//connection successful
//console.log(data);
angular.forEach(data, function (value, index){
var date = value.date;//stores the date of the tv shows
angular.forEach(value.episodes, function (tvshow, …Run Code Online (Sandbox Code Playgroud) 我无法弄清楚这段代码中的类型错误是什么
import React from 'react';
interface IMenu {
items: {
title: string,
active: boolean,
label: string
}[]
}
type Action =
| { type: 'SET_ACTIVE', label: string }
const initialState: IMenu = {
items: [
{ title: 'Home', active: false, label: 'home' },
{ title: 'Customer', active: false, label: 'customer' },
{ title: 'Employee', active: false, label: 'employee' },
{ title: 'Report', active: false, label: 'report' },
]
}
const reducer = (state: IMenu = initialState, action: Action) => { …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 express 服务器提供静态资产,该服务器上也安装了 Apollo Server,但这是与express.static配置相关的问题。这是我的文件夹结构的屏幕截图
这是快速配置的代码。它位于里面/config/app.js
import express from 'express';
import bodyParser from 'body-parser';
import morgan from 'morgan';
import cookieParser from 'cookie-parser';
import cors from 'cors';
import path from 'path';
const PORT = process.env.PORT || 3001;
const environment = process.env.NODE_ENV || 'development';
const loggingType = environment === 'development' ? 'dev' : 'tiny';
const app = express();
app.use(
bodyParser.json({ limit: 1024 * 1024 * 2000, type: 'application/json' })
);
app.use(morgan(loggingType));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, './assets/images')));
export default app;
Run Code Online (Sandbox Code Playgroud)
如果我尝试访问 localhost:3001/images,它会说 …
我正在使用.net MVC5框架开发Web应用程序.我的视图从模型中获取信息,并在两个单独的选择元素中显示建筑类型和楼层数.但是,我只需要显示独特的建筑类型和楼层数信息.如果问题的形象下面
我不知道该怎么做.这是该页面的代码:
@model IEnumerable<BIRDSResidential.Models.ResidentialBuilding>
@{
ViewBag.Title = "ResidentialBuilding";
}
<div class="row">
<div class="col-md-3">
<select>
@foreach (var item in Model)
{
<option value="">@Html.DisplayFor(modelItem => item.type)</option>
}
</select>
</div>
<div class="col-md-3">
<select>
@foreach (var item in Model)
{
<option value="">@Html.DisplayFor(modelItem => item.stories)</option>
}
</select>
</div>
<div class="col-md-offset-5 col-md-1">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-info-sign"></span>
</button>
</div>
</div
Run Code Online (Sandbox Code Playgroud)
>
编辑
我将上面的代码更新为以下内容:
<div class="row">
<div class="col-md-3">
@Html.DropDownList("ResidentialBuilding", new SelectList(Model.Select(x => x.type).Distinct()))
</div>
<div class="col-md-3">
@Html.DropDownList("ResidentialBuilding", new SelectList(Model.Select(x => x.stories).Distinct()))
</div>
<div class="col-md-3"> …Run Code Online (Sandbox Code Playgroud) .net ×1
angularjs ×1
express ×1
javascript ×1
node.js ×1
razor ×1
react-hooks ×1
reactjs ×1
types ×1
typescript ×1