小编art*_*tgb的帖子

对AngularJS资源保存操作的承诺

我目前正在开发REST + AngularJS应用程序.

关于资源保存行动的承诺我有一点问题.

我的工厂:

App.factory('Course', function($resource) {
    var course = $resource('/AppServer/admin/courses/:courseId', {}, {});

    course.findAll = function() {
        return course.query();
    };

    course.findById = function(id) {
        return course.get({
            courseId : id
        });

    };

    course.saveCourse = function(course) {
        return course.$save();
    }

    return course;
});
Run Code Online (Sandbox Code Playgroud)

我的控制器:

App.controller('CourseEditController', function($scope, $routeParams, $location, Course, FlashMessage) {
    // load course into edit form
    $scope.course = Course.findById($routeParams.courseId);

    // save edited course and print flash message
    $scope.saveCourse = function() {
        var savedCourse = Course.saveCourse($scope.course);

        savedCourse.$then(function(httpResponse) {
            FlashMessage.set("Die Änderungen am …
Run Code Online (Sandbox Code Playgroud)

html javascript rest angularjs

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

Angular对ng-src中的url进行编码,并用%2F和'?'替换'/' 与%3F

我有一个带URL的Kibana仪表板:

/logquery/app/kibana#/dashboard/Some-Dashboard?someParameters
Run Code Online (Sandbox Code Playgroud)

我有一个Web应用程序,我试图在上面嵌入仪表板<iframe>.Web应用程序中的URL如下所示

/dashboards/logquery/app/kibana#/dashboard/Some-Dashboard?someParameters
Run Code Online (Sandbox Code Playgroud)

在AngularJs中,我正在做:

ctrl.dashboardUrl = $location.url().replace('/dashboards', '');
Run Code Online (Sandbox Code Playgroud)

在我看来:

<div ng-controller="DashboardCtrl as ctrl">
    <div class="iframe-container">
        <iframe ng-src="{{ctrl.dashboardUrl | trustAsUrl}}"
                height="100%"
                width="100%"
                ng-cloak
                frameborder="0"
                marginheight="0"
                marginwidth="0"></iframe>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

trustAsUrl 过滤器如下:

filtersGroup.filter('trustAsUrl', [
    '$sce',
    function ($sce) {
        return function (val) {
            return $sce.trustAsResourceUrl(val);
        };
    }]);
Run Code Online (Sandbox Code Playgroud)

我有:

$locationProvider.html5Mode({
                enabled: true,
                requireBase: false,
                rewriteLinks: false
            });
Run Code Online (Sandbox Code Playgroud)

这会导致/后面的字符/kibana#与被替换%2F,并?%3F导致Kibana没有能够找到所需的仪表板.

我怎么能克服这个?谢谢!

javascript encoding urlencode angularjs kibana

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

mac错误:找不到pkg-config(即使已经安装了pkg-config)

我已经阅读了几篇关于此的文章。
但是他们并没有从我这里解决。

请查看信息

brew install pkg-config
Run Code Online (Sandbox Code Playgroud)

然后完成安装

Rangers-iMac:dash ranger$ which pkg-config
/usr/local/bin/pkg-config
Run Code Online (Sandbox Code Playgroud)

这意味着已安装pkg-config。

Rangers-iMac:dash ranger$ ./configure
...
checking for exit in -lboost_chrono-mt... yes
checking whether the Boost::Unit_Test_Framework library is available... yes
checking for dynamic linked boost test... yes
configure: error: pkg-config not found.
Run Code Online (Sandbox Code Playgroud)

这意味着configure找不到pkg-config。

我认为问题出在PATH,但我不知道该如何解决。

admin package

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

Fabric JS:文本对象的选择区域大于文本的实际大小

我们正在使用Fabric JS将文本和图像对象添加到画布.

但是当我们添加任何文本对象并选择它时,它会显示大于文本实际大小的选择区域.

请参阅此链接以查看屏幕截图.

我们使用以下代码添加文本对象.

var text_object = new fabric.Text('00', {
                    fontSize: 192,
                    fontFamily: 'Times New Roman',
                    padding: 0
                  });
text_object.top = parseInt((canvas.height - text_object.height) / 2);
text_object.left = parseInt((canvas.width - text_object.width) / 2);
text_object.lockUniScaling = true;
canvas.add(text_object);
canvas.renderAll();
canvas.setActiveObject(text_object);

主要问题是当我们尝试获取添加的文本对象的宽度和高度时; 它给出了文本对象选择区域的宽度和高度,而不是文本的实际大小.

我们如何使文本对象的选择区域与文本的实际大小相同?

或者如何在没有选择区域的情况下获得文本的实际大小?

fabricjs

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

单击 routerLink 到子路由 Angular 2 后视图不会改变

嘿,我遇到了这个问题,我似乎无法弄清楚出了什么问题,基本上我有一个routerLink转到子路线的路径,网址更改为我想要的路线,但视图没有更新到链接的组件到当前活动的子路由

应用程序组件.ts

<app-header></app-header>
<router-outlet></router-outlet>
<app-footer></app-footer>
Run Code Online (Sandbox Code Playgroud)

html

<div class="wide component">
    <div class="page-wrap">
        <img class="logo" src="../../assets/img/our-work-component-logo.png"><br>
        <h2>Component Elite</h2>
        <h3>Web portal and promotions</h3>

        <p class="short-description">Lorem Ipsum</p>
        <a routerLink="component" class="button orange-button">View More</a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

应用程序模块.ts

import { OurWorkComponent } from './our-work/our-work.component';
import { ComponentComponent } from './our-work-content/component/component.component'

export const ROUTES: Routes = [
  { path: 'our-work', component: OurWorkComponent,
      children: [
         { path: 'component', component: ComponentComponent }
      ]
  }
];

@ngModule({
  declarations: [
     OurWorkComponent,
     ComponentComponent
  ],
  imports: [
     BrowserModule,
     RouterModule.forRoot(ROUTES)
  ],
  providers: [], …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

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

Javascript将Promise放入数组

我正在尝试创建一个Promise数组,并用来调用它们Promise.all

我在将函数正确推入数组时遇到麻烦,似乎正在调用它们,而不是插入并等待Promise.all()

function findSpecialAbility(players, gameId, message) {
  return new Promise(function(resolve, reject) {
    let playersWithSpecials = _.reject(players, function(p) {
      return p.role === 'alphaWolf' ||
        p.role === 'betaWolf' ||
        p.role === 'villager' ||
        p.role === 'alchemist' ||
        p.targetId === 0 ||
        p.abilityUsed === true;
    });
    if (playersWithSpecials.length === 0) {
      resolve();
    } else {
      let specialsToUse = [];
      for (let i = 0, j = playersWithSpecials.length; i < j; i++) {
        specialsToUse.push(useSpecialAbility(playersWithSpecials[i], gameId, message, players));
      }
      //Promise.all(specialsToUse).then(r = …
Run Code Online (Sandbox Code Playgroud)

javascript arrays function es6-promise

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

如何在Angular中实现多线程?

https://www.npmjs.com/package/threads

在我看来,我们可以在Angular中使用此包来运行线程。但是我很难实现这一点。无论如何在Angular中使用线程?如何在Angular中使用线程?

javascript multithreading angular

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

基于表单 ID 或名称的 FormData

我有一个表单数据之外的按钮。当我提交表单时,我可以获得序列化值,但不能获得FormData. 我怎样才能得到FormData?

function submitForm() {
  console.log($('#form1').serialize());
  console.log(new FormData(document.getElementById('form1')));
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id="form1" name="form1">
    <input type="firstname" value="First Name" name="firstname">
    <input type="lastname" value="Last Name" name="lastname">
</form>
<button onclick="submitForm()">Submit</button>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

如何检查html元素是否包含它自己的文本(包含textNode)

我将检查html元素是否包含它自己的文本.

例子是
<div>Text<tag></tag>Text</div><div>Text</div>.

有些不合适的事情是 <div><tag></tag><p></p></div>

我的代码片段是

flag = false;
for ( var j = 0; j < item.childNodes.length; j ++){
    if(item.childNodes[j].tagName == ""){
        flag = true;
    }
}
Run Code Online (Sandbox Code Playgroud)

但它没有用,有人可以帮助我吗?

我所期待的是
<div>Text<tag></tag>Text</div>儿童节点Text,<tag></tag>Text.但事实并非如此.

html javascript dom

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

如何隐藏 HTML 文本直到单击

我正在尝试学习如何使用 jQuery 切换 HTML 文本,这本身很容易,但我希望文本自动隐藏,直到用按钮单击它。我查了一下,我找不到如何做到这一点。我认为这应该很容易,而且我有这个部分

<h4 id="text1">This is some toggleable text</h4>

$(document).ready(function(){
    $("#button1").click(function(){
      $("#text1").toggle();
    });
});
Run Code Online (Sandbox Code Playgroud)

作为常规切换可以正常工作,但这会将文本留在那里,直到第一次点击。

代码笔:https ://codepen.io/anon/pen/bYYeEB

html javascript css jquery twitter-bootstrap-4

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