小编Sup*_*nja的帖子

Angularjs:控制器中的$ filter

让此过滤器工作有问题.

$scope.imgCollection.then(function (images) {
    $scope.images = images.thisGal_images;

    if ($scope.images[0].order == '0') {
        console.log('orgName');
        $scope.images = $filter('orderBy')($scope.images, 'orgName');
    } else {
        console.log('sort order');
        $scope.images = $filter('orderBy')($scope.images, 'sortOrder');
        console.log($scope.images);
    }
});
Run Code Online (Sandbox Code Playgroud)

$ scope.images返回数据库中的图像列表.在初始上载时,sortOrder列填充为'0',因为它们可以通过ui:sortable进行排序.因此,在初始视图中,我将排序顺序基于文件名.在初始视图之后写入DB并且第一个图像被赋予sortOrder为1并从那里递增.

这可能是我对$ filter的误解,但是$scope.images = $filter('orderBy')($scope.images,'sortOrder');没有根据sortOrder命令我的$ scope.images.

谢谢

angularjs

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

Webstorm:向上或向下移动线

使用Webstorm8,我一直无法弄清楚当使用向上或向下移动线时,它不会将线放在函数内部,而是跳过函数,或者根据方向将可移动线放置在函数的顶部或底部线条运动.任何想法如何在Sublime中发生如何向上或向下移动一个行号?

webstorm

9
推荐指数
2
解决办法
5675
查看次数

Codeigniter - Bootstrap Modal - 传递数据

我对Codeigniter很陌生,并且在我学习的过程中追求最佳实践.目前我有一个通过DB生成的表

HTML表格

<tr>
    <td>
      <a class="galName" href="#myModal" data-toggle="modal" >
        <?php echo $gal['name']; ?>
      </a>
    </td>
    <td>
      <?php echo $gal['clientName']; ?>
    </td>
</tr>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)

模态

<div class="modal fade hide modal-creator" id="myModal" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Edit Gallery</h3>
    </div>
    <div class="modal-body"><?php echo form_open('url'); ?>

    <div class="row">
        <div class="span5">
            <?php print_r($galleryName); ?>
            <div class="control-group">
                <?php
                    $galleryName = array(
                        'id'            => 'galleryName',
                        'name'          => 'galleryName',
                        'placeholder'   => 'Gallery Name',
                        'required'      => 'required',
                    );
                    echo form_label('Gallery Name:', 'galleryName'); …
Run Code Online (Sandbox Code Playgroud)

php codeigniter twitter-bootstrap

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

jQuery/javascript - 加载前获取图像大小

我有一个上传后呈现为缩略图的图像列表.我的问题是我需要完全上传的图像的尺寸,以便我可以运行调整大小功能,如果大小不正确.

构建图像列表的功能

function buildEditList(json, galleryID)
{
    //Hide the list
    $sortable = $('#sortable');
    $sortable.hide();

    for(i = 0, j = json.revision_images.length; i < j; i++) {
        $sortable.append(
            "<li id='image_" + json.revision_images[i].id + "'><a class=\"ui-lightbox\" href=\"../data/gallery/"
            + galleryID
            + "/images/album/"
            + json.revision_images[i].OrgImageName
            + "\"><img id=\""
            + json.revision_images[i].id
            + "\" alt=\"\" src=\"../data/gallery/"
            + galleryID 
            + "/images/album/" 
            + json.revision_images[i].OrgImageName 
            + "\"/></a></li>"
        ).hide();
    }
    //Set first and last li to 50% so that it fits the format
    $('#sortable li img').first().css('width','50%');
    $('#sortable li img').last().css('width', '50%');

    //Fade images …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

Angularjs $ http.post,将数组传递给PHP

我正在使用服务来更新数据库表.

myApp.factory('createGal', function ($http, $q)
{
    return {
        createGal: function ()
        {
            var deferred = $q.defer();
            var newGalleryArray = {};

            newGalleryArray.galleryName = 'New Image Gallery';
            newGalleryArray.client      = 245;

            $http.post('/beta/images/create', {newGalleryArray: newGalleryArray}).success(function(data)
            {
                console.log(data);
                deferred.resolve(data);
            });

            return deferred.promise;
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

PHP

public function create()
{
    print_r($_POST);
}
Run Code Online (Sandbox Code Playgroud)

数组返回空.我错误地传递了数组吗?

Chrome Dev 在此输入图像描述

谢谢

php angularjs

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

Fabric.js对象:已选中,未选中对象

使用Fabric.js我正在处理一个名为header的文本对象.当选择标题区域时,div将淡入,并带有两个可用于设置文本和填充的输入字段.这对我有用.

我接下来想要处理的是,当取消选择标题对象时,我将淡出我的div.处理header.off()的正确方法是什么?

header.on('selected', function() {

  $('#header-text-edit').fadeIn('fast');

  // watch for header.input changes
  scope.$watch("header.input", function(value) {
    header.text = scope.header.input;
  });

  // watch for header.color changes
  scope.$watch("header.color", function(value) {
    header.fill = scope.header.color;
  });
});
Run Code Online (Sandbox Code Playgroud)

jquery fabricjs angularjs

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

PHP初学者OOP构建一个对象

在此先感谢您的帮助和指导.我终于完成了从线性编程到OOP的转换.我正在上第一堂课,我可以用一点方向.我的第一堂课是一个具有以下属性的画廊

class Gallery
    {
        //Gallery Name
        public $galleryID;
        public $galleryName;

        //Client Name
        public $clientName;

        //Gallery Options
        public $bg_color;
        public $albumAgreement;
        public $maxChanges;
        public $sharing_on;

        //Revisions
        public $revisions;
}
Run Code Online (Sandbox Code Playgroud)

因此我的出局看起来像:

Gallery Object
(
    [galleryID] => 
    [galleryName] => 
    [clientName] => 
    [bg_color] => 
    [albumAgreement] => 
    [maxChanges] => 
    [sharing_on] => 
    [revisions] => 
)
Run Code Online (Sandbox Code Playgroud)

我的下一步是我想将'revisions'作为一个对象,以便我的输出看起来像

Gallery Object
(
    [galleryID] => 
    [galleryName] => 
    [clientName] => 
    [bg_color] => 
    [albumAgreement] => 
    [maxChanges] => 
    [sharing_on] => 
    [revisions] => Revisions Object (
        [revisionID] =>
        [revisionName] =>
    )
)
Run Code Online (Sandbox Code Playgroud)

我有什么方向可以选择这样的课程以及课程的样子?

谢谢

php

4
推荐指数
2
解决办法
534
查看次数

使用jQuery添加ng-click事件

作为Angularjs的新手,我需要对此问题提供一些帮助.我正在尝试将ng-click ="getGallery(57)"添加到模态选项卡.通过jQuery添加不是问题,但我意识到当我这样做时,Angular没有编译新添加的ng-click.我有一个简单的控制器

function imageGalleryCtrl ($scope, $http) {

    //get gallery info on click
    $scope.getGallery = function(id)
    {
        $http.post('/beta/images/get_images',{'id': id}).success(function(data)
    {
        $scope.images = data.thisGal_images;
        $scope.images.galID = id;
    });
    };

}
Run Code Online (Sandbox Code Playgroud)

我使用jQuery将ng-click添加到元素中

//Edit image tab to use angularjs
$('#image_edit a').attr('ng-click','getGallery(' + settings.id + ')');
Run Code Online (Sandbox Code Playgroud)

如何强制Angular编译这个新添加的ng-click?

谢谢!

HTML模式:

这是单击图库名称时调用的模态.

<div class="modal fade hide modal-creator" id="imageUploader" tabindex="-1" data-focus-on="input:first">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"></button>
        <h3>Create New Gallery</h3>
    </div>
    <div class="modal-body">
            <ul id="myTab" class="nav nav-tabs">
                <li id="image_home" class="">
                    <a href="#home" data-toggle="tab">Home</a>
                </li>
                <li id="image_upload" class="">
                    <a …
Run Code Online (Sandbox Code Playgroud)

angularjs

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

Javascript:第一个逗号后的换行符

我有一个从与 Google Map API 交互的数据库中提取的地址。显示结果时,我的地址呈现如下:

456 Here Street, City, AL 36723

在之后输入换行符的解决方案是什么

这里街465号

这样地址就会显示为

456 Here Street
City, AL 36723
Run Code Online (Sandbox Code Playgroud)

javascript

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

带控制器的Angularjs指令

我试图用它自己的控制器编写一个指令.

myApp.directive('imageUploadifive', function (createGal)
{
    return {
        restrict: 'A',
        controller: function($scope)
        {
            //create gallery
            $scope.created = createGal.createGal();
            $scope.created.then(function(createGal){
                $scope.gallery.id = createGal.created_id;
                console.log($scope.gallery.id);//returning after the link function
            });

            $scope.gallery.galleryName = "New Image Gallery";
        },
        link: function($scope, element, attrs)
        {
        var id = $scope.gallery.id;
        console.log(id);
            $(element).uploadifive({
                'uploadScript'  : '/beta/images/upload',
                'buttonClass'   : 'uploadifive-button btn btn-primary',
                'queueID'       : 'imageGallery_queue',
                'buttonText'    : 'Select Files',
                'fileSizeLimit' : 500,
                'formData' : {
                    'galleryID' : id
                },
                'onError': function(errorType)
                {
                    alert('There was a problem');
                },
                'onUpload': function()
                { …
Run Code Online (Sandbox Code Playgroud)

angularjs

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