小编ipa*_*yte的帖子

如何使用ng-style设置div的背景图像

基本上我有一个链接,当它被点击时,我显示一个模态.现在我可以在模式上显示其他属性,如标题,除了背景图像!呃!

这是模式:

<div class="modalContainer" ng-style="{'background-image':'url({{selectedMeal.url}})'}">

                <div id="modalHeader"> 
                <div style="padding-top: 10px;">{{selectedMeal.title}}</div>

                </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这些是链接:

<div ng-click='selectMeal(meal)' class="contentItem" ng-repeat='meal in recipes | filter:searchText' ng-style="{'background-image':'url({{ meal.url }})'}">
                    <span id="contentItemHeader">{{ meal.title }}</span>
                    <span id="contentItemLevel">{{ meal.level }}</span>
</div>
Run Code Online (Sandbox Code Playgroud)

JSON:

recipes:[
    {
      "type": "Breakfast",
      "title": "Chili con carne",
      "description": "A spicy and fragrant chili with ground beef, kidney beans, tomatoes, onions and garlic. Best served over rice with a dollop of sour cream and some cheese on top.",
      "ratings": 4,
      "duration": 12,
      "level":"medium",
      "url":"http://31.media.tumblr.com/bc0ea7c5f95701bff499f78b59d23e68/tumblr_mr74z9Lt3O1rs0z5go1_500.jpg",
      "ingredients": 
          [ …
Run Code Online (Sandbox Code Playgroud)

angularjs

32
推荐指数
3
解决办法
8万
查看次数

你如何在 Javascript 中获得音频的分贝级别

我目前正在使用 JavaScript、HTML 和 CSS 制作分贝计可视化工具。

我已经阅读了几个 Web Audio API 教程,但没有任何内容与我想要做的事情相关。

这是我到目前为止:

window.onload = init;

function init() {
  
  var ctx = new webkitAudioContext()
    , url = 'https://dl.dropboxusercontent.com/u/86176287/pbjt.mp3'  
    , audio = new Audio(url)
    // 2048 sample buffer, 1 channel in, 1 channel out  
    , processor = ctx.createJavaScriptNode(2048, 1, 1)
    , meter = document.getElementById('meter')
    , source;
    
  audio.addEventListener('canplaythrough', function(){
    source = ctx.createMediaElementSource(audio);
    source.connect(processor);
    source.connect(ctx.destination);
    processor.connect(ctx.destination);
    audio.play();
  }, false);
  
  // loop through PCM data and calculate average
  // volume for a given 2048 sample buffer …
Run Code Online (Sandbox Code Playgroud)

javascript audio decibel html5-audio

12
推荐指数
1
解决办法
6282
查看次数

如何使用soundcloud Sdk iOS搜索曲目

我已经阅读了适用于iOS的soundcloud的sdk文档,但它似乎没有说到搜索歌曲的任何内容,尽管它谈到了从现有的soundcloud用户列出曲目.那么有没有资源或示例?太感谢了 !

api sdk objective-c ios soundcloud

8
推荐指数
1
解决办法
1634
查看次数

获得数组Javascript的所有整数组合的另一种方法

我想迭代一个数组并找到它们的差值为2的所有对

这是我到目前为止:

var numberOfCases = 5;
var diff = 2;

var input = [1,5,3,4,2];

getPossiblepairs(input);

function getPossiblepairs(input){
    for(cmp in input){
        for(number in input){
            if((input[cmp] - input[number]) == diff){
                console.log("("+input[cmp]+","+input[number]+")");
            }
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

这有效,但我仍然感到内疚使用两个for循环,因为bigO是O(n ^ 2)这是唯一的方法吗?

javascript arrays performance time-complexity

5
推荐指数
1
解决办法
190
查看次数

Jquery Css函数缓慢向div添加属性?

所以基本上我试图在点击另一个时缩放div(从0开始)但是缩放原点应该从点击发生的地方开始.点击应用程序时苹果的功能排序(应用程序从您点击它的位置打开).

问题是尝试设置我成功的比例原点的属性但是当我点击div时,这没有效果!它只适用于我设置超时功能时添加完全缩放它的类

在应用css之前似乎已添加了类:

var xPosSTR = 30+'px';
var yPosSTR = 30+'px';

        $('.box-detail').css({
            'transform-origin':         '' + xPosSTR + ' ' + yPosSTR + ' 0px',
            '-webkit-transform-origin': '' + xPosSTR + ' ' + yPosSTR + ' 0px'
        });

        $(".box-detail").addClass("box-reveal-prop");
Run Code Online (Sandbox Code Playgroud)

类被应用延迟(从指定的原点缩放但需要时间)

var xPosSTR = 30+'px';
var yPosSTR = 30+'px';

        $('.box-detail').css({
            'transform-origin':         '' + xPosSTR + ' ' + yPosSTR + ' 0px',
            '-webkit-transform-origin': '' + xPosSTR + ' ' + yPosSTR + ' 0px'
        });
         setTimeout(function(){
            $(".box-detail").addClass("box-reveal-prop");
         }, 2000);
Run Code Online (Sandbox Code Playgroud)

css:{

.box-detail …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

5
推荐指数
1
解决办法
393
查看次数

如何使用带有git命令的travis合并到另一个分支?

我正在尝试向我的devstack添加一个功能,以便在travis测试通过名为travis的分支时添加自动部署.在此测试通过后,我想将此travis分支合并到主分支并推送到主分支.

到目前为止,当我推送travis分支时,travis运行测试并且一切都成功但我after_success在我的travis.yml文件中遇到了我的git命令问题.

travis.yml

- "npm i -g jasmine-node"
-after_success: 
  - "git fetch"
  - "git checkout master"
  - "git merge travis"
  - "git push origin master"
 branches:
   only:
     - travis
Run Code Online (Sandbox Code Playgroud)

这是travis控制台上的输出:

error: pathspec 'master' did not match any file(s) known to git.
fatal: 'travis' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

非常感谢!

git continuous-integration github travis-ci

5
推荐指数
1
解决办法
1764
查看次数

如何将变量从app.js导出到Node js中的另一个路径

我在我的节点项目中使用socket.io并想知道如何导出io变量

这是我到目前为止所做的,但我得到这个错误: Object #<Object> has no method 'on'

在app.js中:

        var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./routes/index')(io);
var users = require('./routes/user');

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(4000);

require('./routes/index')(io);

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// app.use(favicon(__dirname + '/public/img/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes); …
Run Code Online (Sandbox Code Playgroud)

node.js express socket.io

4
推荐指数
1
解决办法
4774
查看次数

你应该在Realm iOS中异步存储图像吗?

我目前正在使用Realm来创建我正在创建的应用程序中的数据持久性.

我想要做的是,当应用程序首次打开时,它从api中获取数据.我希望从获取的数据中获取所有内容并将其存储,以便即使没有活动的Internet连接也可以使用该应用程序.

然而,我可以实现存储字符串,如用户名和手机号码,但我不知道如何存储图像.

这是我到目前为止:

@interface User : RLMObject

@property NSString *userName;
@property NSString *mobileNumber;
@property NSData *avatarData;

@end


- (void)viewDidLoad {
    [super viewDidLoad];

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:[NSString stringWithFormat:@"%@users?auth_token=%@",BASE_URL,AUTHENTICATION_TOKEN]parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        [self storeFetchedData: responseObject];

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    }];

}

- (void)storeFetchedData:(NSDictionary *)list {
    RLMRealm *realm = [RLMRealm defaultRealm];
    [realm beginWriteTransaction];

    for (id slUser in list) {
        User *user = [[User alloc] init];
        user.userName = slUser[@"name"];
        user.realName = slUser[@"mobileNumber"];

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){

            user.avatarData …
Run Code Online (Sandbox Code Playgroud)

objective-c realm ios afnetworking

2
推荐指数
1
解决办法
1050
查看次数

Heroku 在部署应用程序时未安装依赖项

iv 我的应用程序在 Heroku 上运行了一个月,今天我添加了登录功能。我推送了在本地计算机上运行良好的更新,但是当我在 heroku 上启动时,我收到错误消息

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details
Run Code Online (Sandbox Code Playgroud)

这是我在 heroku 控制台上遇到的错误:

           ^
2014-08-23T03:33:15.894737+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-08-23T03:33:15.694754+00:00 app[web.1]: > application-name@0.0.1 start /app
2014-08-23T03:33:15.694756+00:00 app[web.1]: > node ./bin/www
2014-08-23T03:33:15.892108+00:00 app[web.1]: 
2014-08-23T03:33:15.892717+00:00 app[web.1]:     throw err;
2014-08-23T03:33:15.894741+00:00 app[web.1]:     at require (module.js:380:17)
2014-08-23T03:33:15.894747+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-08-23T03:33:15.894731+00:00 app[web.1]: Error: Cannot find …
Run Code Online (Sandbox Code Playgroud)

heroku node.js

1
推荐指数
1
解决办法
6464
查看次数

Jquery函数没被调用?

请问为什么地球上的功能不是我花了将近一个小时的时间:

这是jquery:

function toggleDivs() {
    var $inner = $("#inner");

    // See which <divs> should be animated in/out.
    if ($inner.position().left == 0) {
        $inner.animate({
            left: "-400px"
        });
    }
    else {
        $inner.animate({
            left: "0px"
        });
    }
}

$("button").bind("click", function() {
        alert("Hello");
    toggleDivs();
});
Run Code Online (Sandbox Code Playgroud)

这是我的html中的头部分

<head>
<script type="text/javascript" src="PageScript.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Lato:100,400' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="PageStyle.css">
</head>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

0
推荐指数
1
解决办法
94
查看次数