小编Mar*_*kLi的帖子

Yeoman使用Sass文件的工作流程是什么?

我尝试使用自耕农,但我不知道如何使用自己的sass文件.

grunt server

Sass文件被观看并编译成

.tmp/styles/

但是没有引用已编译的样式表,除了 <link rel="stylesheet" href="styles/main.css">

那么,在开发过程中使用index.html中编译的sass文件的推荐方法是什么?

例如grunt server,如果我将样式更改app/styles/my.sass.tmp/styles/my.css,则会被覆盖,并且它位于服务器之外(localhost:9000).因此,无法将其链接起来index.html.

随着grunt build一切内main.css包括my.sass但发展过程中,我不知道如何使用我自己的SASS文件index.html.

你能举个简单的例子吗?

这是默认的yeoman安装.我这样做了:

  1. yo angular test
  2. 我加 app/styles/style.sass
  3. grunt server这个汇编style.sass成了.tmp/styles/style.css
  4. 现在我不知道如何style.css在html中包含它

(对不起,这可能是一个愚蠢的问题,但我也是新人,也是自己的咕噜声)

这是来自yeoman的Gruntfile.js:

'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var …
Run Code Online (Sandbox Code Playgroud)

sass gruntjs yeoman compass-sass

38
推荐指数
3
解决办法
2万
查看次数

混合REST API复数和单数用于不同的资源?

REST api的多种形式更自然,更常用,例如/api/usersapi/users/123.

但是对于某些资源来说并不自然,例如:

  • /api/login - 准确登录一个用户
  • /api/profile - 获取已登录用户的个人资料

此资源永远不会用于我的应用程序中的一个对象/模型.

另一方面,我读到在资源名称中混合复数和单数形式并不是一种好的做法(http://pages.apigee.com/web-api-design-ebook.html).

所以我考虑做什么:

  1. 对所有人使用单数
  2. 使用复数(有一些像愚蠢的形式/api/logins)
  3. 为了不一致并且几乎所有资源都使用复数期望一些特殊资源,例如/api/login或者/api/profile总是与一个对象/模型一起使用.

什么是更好的方法?

rest resources uri naming-conventions

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

如何在angular指令中验证动态表单字段?

我想用指令创建的字段创建表单.数据的数据绑定正常工作但验证不起作用.

这是html:

<body ng-controller="MainCtrl">
  <h1>form</h1>
  <form name="form">
      <div ng-repeat="conf in config">
          <div field data="data" conf="conf"></div>
      </div>
  </form>
  <pre>{{data|json}}</pre>
</body>
Run Code Online (Sandbox Code Playgroud)

控制器和现场指令:

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
    $scope.data = {name: '', age: ''}
    $scope.config = [
        {field: 'name', required:true},
        {field: 'age'}
    ];
});

app.directive('field', function ($compile) {
    return {
        scope: {
            data: '=',
            conf: '='
        },
        link: function linkFn(scope, element, attrs) {
            // field container
            var row = angular.element('<div></div>');

            // label
            row.append(scope.conf.field + ': ');

            // field input
            var …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive angularjs-scope

8
推荐指数
2
解决办法
6200
查看次数

是否有用于解析gettext PO POT文件的PHP库?

如果不是在PHP中,可以使用一些命令行工具将PO文件转换为某种结构化格式,例如XML或其他一些我可以在PHP中简单处理的文件?

php parsing gettext po

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

如何将变量中的ng-click可执行操作(&)传递给指令?

带有指令的HTML视图:

<div click aaa="aaa()" action="action"></div>
Run Code Online (Sandbox Code Playgroud)

控制器:我喜欢在$ scope.action中传递函数bbb():

app.controller('MainCtrl', function($scope) {
    $scope.aaa = function () { alert('aaa'); }
    $scope.bbb = function () { alert('bbb'); }

    $scope.action = 'bbb()';
});
Run Code Online (Sandbox Code Playgroud)

指示:

app.directive('click', function () {
    return {
        scope: {
            aaa: '&',
            action: '&'
        },
        template: 
            '<button ng-click="aaa()">show aaa (work ok)</button>' +
            '<button ng-click="action">show bbb (not work)</button>' +
            '<br>How to pass ng-click action in variable into directive?'
    }
});
Run Code Online (Sandbox Code Playgroud)

我不知道如何评价action被替换bbb().

这里是plunker:http://plnkr.co/edit/d8DtsNARKPPJwk2SO2WJ

angularjs angularjs-directive

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

如何设置茉莉为业力e2e测试角应用程序?

我尝试使用业力和茉莉与自耕农创建e2e测试.在我的karma-e2e.conf.js添加茉莉花:

files = [
   JASMINE,
   JASMINE_ADAPTER,
   ANGULAR_SCENARIO,
   ANGULAR_SCENARIO_ADAPTER,
   'test/e2e/**/*.js'
];
Run Code Online (Sandbox Code Playgroud)

一个需要异步测试,所以我需要使用runs,waits,waitsFor(https://github.com/pivotal/jasmine/wiki/Asynchronous-specs)

但如果我尝试使用它:

it('test', function () {
    runs(function () {
        ...
    });
});
Run Code Online (Sandbox Code Playgroud)

Scenatio test runner返回:

TypeError: Cannot call method 'runs' of null
    at runs (http://localhost:8080/adapter/lib/jasmine.js:562:32)
    at Object.<anonymous> (http://localhost:8080/base/test/e2e/eduUser.js:42:3)
    at Object.angular.scenario.SpecRunner.run   (http://localhost:8080/adapter/lib/angular-scenario.js:27057:15)
    at Object.run (http://localhost:8080/adapter/lib/angular-scenario.js:10169:18)
Run Code Online (Sandbox Code Playgroud)

我不知道问题出在哪里.你能帮我吗?

testing jasmine angularjs yeoman karma-runner

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