小编con*_*adj的帖子

Angular 1.3 + ui-router + generator-ng-poly嵌入嵌套(?)视图不起作用

我是Angular,ui-router和generator-ng-poly的新手,我希望有人能帮助解决一个简单的语法问题.

我正在使用generator-ng-poly进行新项目,并使用ui-router和HTML在基于Angular 1.3的应用程序的"深层示例"中工作.

首先,我创建了一个"home"模块,然后在其中创建了一个"header"模块.所以...

 yo ng-poly:module home
 yo ng-poly:module home/header
Run Code Online (Sandbox Code Playgroud)

这给了我这两个控制器:app/home/home.js

    (function () {
  'use strict';

  /* @ngdoc object
   * @name home
   * @requires $stateProvider
   *
   * @description
   *
   */
  angular
    .module('home', [
      'ui.router',
      'home.header'
    ]);

  angular
    .module('home')
    .config(config);

  function config($stateProvider) {
    $stateProvider
      .state('home', {
        url: '/home',
        templateUrl: 'home/home.tpl.html',
        controller: 'HomeCtrl',
        controllerAs: 'home'
      });
  }

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

和app/home/header/header.js

(function () {
  'use strict';

  /* @ngdoc object
   * @name home.header
   * @requires $stateProvider
   *
   * @description
   *
   */
  angular
    .module('home.header', …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui-router yo

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

Gulp将Node应用程序的dist文件夹部署到Heroku

我是node,git,github和Heroku的新手,我正在努力找出将我的应用程序发送到Heroku的最佳方式,而不会使用我编译的缩小应用程序混乱使用repo而不会在Heroku中做太多.

我的node.js项目看起来有点像这样:

- client
     ... code
- server
     ... code
- node_modules
- package.json
- gulpfile.js
- dist
    - client
    - server
Run Code Online (Sandbox Code Playgroud)

除了node_modulesdist进入github 之外的所有东西.

gulpfile编译,缩小和连接准备发布的所有内容 dist.如何将dist文件夹推送到Heroku,而不是将其放入github?什么是最佳做法?我宁愿不把我的gulpfile发送到Heroku,因为它意味着移动package.json中的devDependencies并使用post更新脚本,因为它将项目与Heroku联系起来比我想要的多.

在这两个帖子中总结了不使用post hook的原因:https://stackoverflow.com/a/15050864/344022&https://stackoverflow.com/a/21056644/344022,遗憾的是他们没有提供易于理解的替代方案.

git github heroku node.js gulp

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

在Bootstrap 3中启用触摸事件的推荐方法?

现在Bootstrap 3已启用,启用触摸的推荐选项是什么?和以前一样,bootstrap.js中没有很多触摸事件,尽管它应该是一个移动的第一个框架.

在github 上发现的最后一件事建议使用fastclick.js,但那是在v3.0发布之前.

javascript mobile touch twitter-bootstrap

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

使用Gulp.js自动运行Jasmine测试?

我有基本的Gulp任务,并设置了基本的Jasmine测试运行器.如何使用Gulp在文件保存上运行我的Jasmine测试并向我显示输出?茉莉花在哪里?

我对这些库以及JS构建和单元测试系统都是新手,所以不确定问题和最佳实践,我没有在网上发现任何基本的东西对我来说:-)

javascript jasmine gulp

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

在更改为包含数组时更新Aurelia观察到的属性

我有一个简单的类,Event具有计算属性:

import moment from 'moment';

export class Event {
    constructor(data) {
        Object.assign(this, data);
    }

    get playedFromNow() { 
        return moment(this.CreateDate).fromNow();
    }
}
Run Code Online (Sandbox Code Playgroud)

playedFromNow只返回一个基于CreateDate属性的字符串,比如7 minutes ago.

viewmodel获取一系列事件,视图呈现事件.每次发生新事件(每隔几分钟),阵列就会通过websockets进行更新.

<div repeat.for="event of events">
    <div class="media-body">
        <h4 class="media-heading">${event.title} <small>${event.playedFromNow}</small></h4>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

和(相关)viewmodel代码:

let  socket = io();
socket.on(`new-event`, (data) => { 
  this.events.unshift(new Event(data)); // add to the event array at the top
});

// subscribe
let subscription = bindingEngine.collectionObserver(this.events).subscribe();
// unsubscribe
subscription.dispose();
Run Code Online (Sandbox Code Playgroud)

目前该属性是脏的检查,这意味着该属性被检查并经常更改 - 这是有点不必要的,屏幕上显示了很多事件,所以我担心随着时间的推移性能.有没有办法可以根据数组绑定触发重新计算并更新VM中的代码?:

javascript aurelia aurelia-binding

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

获取语​​言环境的货币符号

如何获取给定货币字符串(“GBP”、“USD”等)的货币符号?我想出的最好的似乎冗长可笑,还有其他方法还是我最好使用查找表?

const userLocale = "EN-gb";
const userCurrency = "GBP";
const withValueEl = document.querySelector(".withValue");
const withoutValueEl = document.querySelector(".withoutValue");
const valueWithCurrency = Number(0).toLocaleString(userLocale, {
  style: "currency",
  currency: userCurrency,
  minimumFractionDigits: 2
});
const valueWithoutCurrency = valueWithCurrency.replace(Number(0).toLocaleString(userLocale, {
  minimumFractionDigits: 2
}), "")

withValueEl.innerHTML = valueWithCurrency
withoutValueEl.innerHTML = valueWithoutCurrency
Run Code Online (Sandbox Code Playgroud)
With value:<span class="withValue"></span><br /> Without value:<span class="withoutValue"></span><br />
Run Code Online (Sandbox Code Playgroud)

javascript locale symbols currency

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