我正在使用AngularJS,jQuery,HTML,CSS和Bootstrap创建一个Web应用程序,我想从我的JSON中选择一些位于Apache2服务器中的图像链接并使用它们来在我的主页面中呈现这些图像.我也想像旋转木马一样刷它们.为了做到这一点,我正在尝试使用iDangero.us Swiper.
当我用3个分开的div选择我的图像时,我没有问题.我得到了我的图像然后我可以按照我想要的方式刷它们.我这样做如下所示:
main.html中:
<div ng-init="initGetRequestMain()">
<div class="swiper-slide" ng-click="swipers()"
style="{{data.background1}}"></div>
<div class="swiper-slide" ng-click="swipers()"
style="{{data.background2}}"></div>
<div class="swiper-slide" ng-click="swipers()"
style="{{data.background3}}"></div>
<script src="scripts/custom/main/swipers.js"></script>
</div>
Run Code Online (Sandbox Code Playgroud)
我使用Swiper从一个图像滑动到另一个图像,它似乎应该工作.这是一个jQuery插件,你可以在这个链接上看到一些演示.
Swipers.js:
angular.module('swipers', [])
.controller('',[
$(document).ready(function (){
var swiper = new Swiper('.swiper-container',{
direction: 'horizontal',
pagination: '.swiper-pagination',
paginationClickable: true
})
})]);
Run Code Online (Sandbox Code Playgroud)
JSON:
"background1":"background-image: url(images/img1.jpg)",
"background2":"background-image: url(images/img2.jpg)",
"background3":"background-image: url(images/img3.jpg)"
Run Code Online (Sandbox Code Playgroud)
mainController.js:
myApp.controller('MainController', ["$scope","$http",
function($scope,$http){
$scope.initGetRequestMain = function(){
$http.get('http://localhost/main.json').success(function(data){
$scope.data=data;
})
}
}]);
Run Code Online (Sandbox Code Playgroud)
问题是,当我尝试使用ng-repeat而不是3个分开的div时,我再也看不到它们了,我的Swiper脚本在完全加载之前就会触发.我的控制台或JSON中没有错误(使用JSONLint验证).下面,我在两种情况下都添加了2个输出屏幕截图.
使用3个独立的div:
不使用ng-repeat:
这是我尝试使ng-repeat工作保持与以前相同的控制器和相同的Swiper脚本的代码:
main.html中:
<div ng-init="initGetRequestMain()">
<div ng-repeat="slide in data.slides" isLoaded=""> …Run Code Online (Sandbox Code Playgroud) jquery angularjs angularjs-directive angularjs-ng-repeat swiper
我有一个问题,在某些日子里我无法解决,甚至查看相关的Stack Overflow Q/A.
我正在开发一个应用程序重用Scotch的创建一个MEAN堆栈谷歌地图应用程序教程由艾哈迈德哈克方法.
我正在尝试实现一个使用Google Maps API绘制的应用程序Points,LineStrings以及Polygons哪些坐标包含在存储在MongoDB实例中的GeoJson文件中.
我正在使用Mongoose为我的数据构建Schema并查询我的MongoDB数据库.
我想找到 给定
CP某个点的最近点,并给出用于找到感兴趣点的最大半径 .P0P0's latitude and longitudedistance
鉴于图像结束,我想,例如,如果我插入2000(公里),我的查询将找到距离P0最远2000公里的所有点.在这个例子中,它应该给我P1和P2.
当我只有点数时,我能够做到这一点Mongoose Schema.
我Schema只有标记(点):
// Pulls Mongoose dependency for creating schemas
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// Creates a User Schema.
var MarkerSchema = new Schema({
username: {type: String, required: true},
location: {type: [Number], required: …Run Code Online (Sandbox Code Playgroud) 我在尝试浏览不同的路线时遇到了问题.
我有两个不同的路线模块.
app.routes.ts:
仅包含LoginPage:
export const routes: Routes = [
{
path: 'login',
component: LoginPageComponent,
canActivate: [PreventLoggedInAccess]
},
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: '**',
redirectTo: 'login'
}
];
export const Routing: ModuleWithProviders =
RouterModule.forRoot(routes, { useHash : true });
Run Code Online (Sandbox Code Playgroud)
使用PreventLoggedInAccess.canActivate,如果用户已经登录,则将其重定向到具有/app前缀和子路由的登录部分home.它被定义为:
canActivate(): boolean {
if (!this._authService.isAuthenticated()) {
return true;
}
this._router.navigate(['/app/home']);
return false;
}
Run Code Online (Sandbox Code Playgroud)
pages.routes.ts:
包含/app仅在用户登录时才可访问的所有子路由.这可以通过以下方式实现AuthGuardService.canActivateChild:
export const pageRoutes: Routes = [ …Run Code Online (Sandbox Code Playgroud) typescript angular-routing angular angular-router-guards angular-router
我正在尝试使用MEAN构建一个应用程序,但现在我在尝试时遇到困难find linestrings intersecting on another one given its name.
例如,给定下面的图像,poly1并且poly2应该有交叉而poly3不是.
我们假设poly1有以下坐标和以下坐标JSON:
{
"_id" : ObjectId("57ab2107505ab11b1bd8422e"),
"name" : "poly1",
"updated_at" : ISODate("2016-08-10T12:41:43.789+0000"),
"created_at" : ISODate("2016-08-10T12:41:43.780+0000"),
"geo" : {
"coordinates" : [ [14.59, 24.847], [28.477, 15.961] ],
"type" : "LineString"
},
"__v" : NumberInt(0)
}
Run Code Online (Sandbox Code Playgroud)
当我运行的查询上MongoChef,我觉得都poly1和poly2我不觉得poly3像我想:
{
geo :{
$geoIntersects:{
$geometry :{
type: "LineString" ,
coordinates: [ [14.59, 24.847], [28.477, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用aws-sdk-go设置AWS-lambda ,只要将新user内容添加到某个dynamodb表,就会触发该事务.
一切都工作得很好,但我找不到解组地图的方法,map[string]DynamoDBAttributeValue如:
{
"name": {
"S" : "John"
},
"residence_address": {
"M": {
"address": {
"S": "some place"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
对于给定的结构,例如,User结构.这里显示了一个map[string]*dynamodb.AttributeValue将一个unmarhaling 到一个给定接口的例子,但我找不到一种方法来做同样的事情,map[string]DynamoDBAttributeValue即使这些类型似乎适合相同的目的.
map[string]DynamoDBAttributeValueevents.DynamoDBEvents从包中返回github.com/aws/aws-lambda-go/events.这是我的代码:
package handler
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/dynamodb"
)
func HandleDynamoDBRequest(ctx context.Context, e events.DynamoDBEvent) {
for _, record := range e.Records {
if record.EventName == "INSERT" {
// User Struct
var dynamoUser …Run Code Online (Sandbox Code Playgroud) 我遇到了RequireJS的问题.从本质上讲,我无法访问另一个文件中另一个文件中定义的函数.
我需要这样做,因为我想导出一个给定的函数子集,如
define('submodule', [], function() {
let myFunction1 = function(){ return "Hello"; }
let myFunction2 = function(){ return " From"; }
let myFunction3 = function(){ return " Submodule!"; }
return {
myFunction1 : myFunction1,
myFunction2 : myFunction2,
myFunction3 : myFunction3,
};
});
Run Code Online (Sandbox Code Playgroud)
并从另一个文件访问它们
define('main', ['config', 'sub1', 'sub2', 'submodule'],
function(config, sub1, sub2, submodule) {
//Config
alert(config.conf);
//Submodule
let callSubmodule = function() {
alert(submodule.myFunction1() +
submodule.myFunction2() +
submodule.myFunction3());
}
//sub1
let callSub1 = function() {
alert(sub1.myFunction1());
}
//sub2
let callSub2 …Run Code Online (Sandbox Code Playgroud) 正如标题中所述,我面临的问题是,只有在这些情况下,我的所有效果才能正常工作:
如果我设法注销并与其他用户登录,则会出现问题.只有每个ngOnInit执行动作调度的人都会被调用.没有效果被解雇.
我有两个模块,app.module和pages.module.第一个只声明未登录用户的组件,例如login/register/reset.第二个仅声明登录用户的组件.
在app.module.ts中我导入了所有的reducers并将其设置为StoreModule.provideStore(reducer).在pages.module.ts,另一个模块中,我导入并激活了类似的效果EffectsModule.run(TestEffects).
使用以下代码仅ngOnInit调用内部日志.效果中的日志永远不会被调用.
test.component.ts:
/** ngrx **/
import * as reducers from '../../reducers';
import * as testActions from './actions/test.actions';
. . .
constructor(private _store: Store<reducers.State>){
this._store.select(reducers.getStuff)
.subscribe(stuff => console.log(stuff));
}
ngOnInit() {
console.log('Dispatching Load Action');
this._store.dispatch(new testActions.LoadAction());
}
Run Code Online (Sandbox Code Playgroud)
test.actions.ts:
import { Action } from '@ngrx/store';
export const ActionTypes = {
LOAD: type('[Test] Load'),
LOAD_SUCCESS: type('[Test] Load Success'),
}; …Run Code Online (Sandbox Code Playgroud) 我正在使用 Golang 构建 REST API,但在尝试正确编组 Json 切片时遇到一些麻烦。即使在网上查看了几个问题和答案之后,我也已经摸不着头脑有一段时间了。
本质上,我有一个Redis客户端,它在调用后调用,并-X GET /todo/吐出一部分todos
[{"content":"test6","id":"46"} {"content":"test5","id":"45"}] //[]string
Run Code Online (Sandbox Code Playgroud)
现在,我想Response根据我todos是否找到的事实返回给定的,所以我有一个Struct喜欢
type Response struct {
Status string
Data []string
}
Run Code Online (Sandbox Code Playgroud)
然后,如果我发现一些todos我只是Marshal一个 json
if(len(todos) > 0){
res := SliceResponse{"Ok", todos}
response, _ = json.Marshal(res)
}
Run Code Online (Sandbox Code Playgroud)
并且,为了删除\响应中不必要的内容,我使用bytes.Replace类似
response = bytes.Replace(response, []byte("\\"), []byte(""), -1)
Run Code Online (Sandbox Code Playgroud)
最后,得到
{
"Status" : "Ok",
"Data" : [
"{"content":"test6","id":"46"}",
"{"content":"test5","id":"45"}"
]
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,每个"之前{和之后的每个 …
如标题中所述,我在尝试设置新内容时遇到以下错误Item:
无法调用类型缺少调用签名的表达式.类型'ItemModel'没有兼容的呼叫签名.
我正在使用BehaviorSubject并在两个不同的状态之间Subject共享一组Item.基本上,我想设置一个选择Item,然后,当进入其详细信息页面,得到它.
这是我的item.model.ts,假设它只有一个id属性:
export class ItemModel {
public id: string;
constructor( id: string ) {
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
这里是我的item.service.ts用途get和set一个Item:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { ItemModel } from './item.model';
@Injectable()
export class ItemService {
public _item = new BehaviorSubject<ItemModel>(null);
item$ = …Run Code Online (Sandbox Code Playgroud) 我正在使用aws-sdk-go和aws-lambda-go构建一个aws lambda ,我遇到了一个小问题.
我想测试我的lambda处理程序.为此,我需要模拟一个有效的context.Context,它包含lamdacontext.LambdaContext的有效属性并且满足lambdacontext.FromContext.
我似乎无法找到建立这样的模拟的方法,因为lambdacontext.FromContext总是回报我_, false.
这是我的主要内容,在events.SNSEvent事件上有一个简单的处理程序:
package main
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-lambda-go/lambdacontext"
)
func main() {
lambda.Start(handleRequest)
}
func handleRequest(ctx context.Context, snsEvent events.SNSEvent) error {
lc, ok := lambdacontext.FromContext(ctx); if !ok {
// Always false
...
return someErr
}
. . .
return nil
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试handleRequest:
package main
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambdacontext"
"github.com/stretchr/testify/assert"
"gitlab.easy-network.it/meg/aml-rekognition/testdata"
"testing"
)
const imgMock …Run Code Online (Sandbox Code Playgroud) angular ×3
go ×3
typescript ×3
angularjs ×2
aws-lambda ×2
aws-sdk-go ×2
javascript ×2
jquery ×2
mongodb ×2
mongoose ×2
node.js ×2
html ×1
json ×1
marshalling ×1
ngrx ×1
ngrx-effects ×1
ngrx-store ×1
requirejs ×1
rxjs ×1
swiper ×1
unit-testing ×1