How to use angular-expressions - 6 common examples

To help you get started, we’ve selected a few angular-expressions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spderosso / deja-vu / designer / src / app / expression.compiler.ts View on Github external
if (!dvExpr) { return { names: [], evaluate: () => undefined }; }
  const match = grammar.match(dvExpr);
  if (match.failed()) {
    throw new Error(match.message);
  }
  const parsedExpr = semantics(match);
  const names: string[] = (parsedExpr.getNames() as string[])
    .map((name) => name
        .replace(/\?/g, '') // ignore elvis operator
        .split('.')
        // tslint:disable-next-line no-magic-numbers
        .slice(0, name.startsWith('$') ? 1 : 3) // $input or cliche.component.input
        .join('.')
    ); // drop object path
  const ngExpr: string = parsedExpr.toNgExpr();
  const evaluate: (scope: Object) => any = expressions.compile(ngExpr);

  return {
    names,
    evaluate,
    parsedExpr
  };
}
github smclab / power-templates / lib / index.js View on Github external
"use strict";

var assign = Object.assign || require('object.assign');
var explodeTree = require('combinatorial-explosion').explodeTree;
var expressions = require("angular-expressions");

// Expressions setup

expressions.filters.or = function (input, def) {
  return (input == null) ? def : input;
};

// Public API

PowerTemplate.BINDINGS_RE = /^\s*\[([\s\S]*)\]\s*$/;

// Factories

module.exports = PowerTemplate;

PowerTemplate.createListView = function (cfg) {
  var powerTemplates = function () {};

  forEachOwnProperty(cfg.templates, function (template, name) {
    powerTemplates[ name ] = new PowerTemplate(template, name);
github komachi / usedcss / src / index.js View on Github external
html('[ng-class], [data-ng-class]').each((i, el) => {
                  let cls = [];
                  let ngcl = html(el).attr('ng-class');
                  if (ngcl) {
                    ngcl = ngcl.replace('::','');
                    cls = cls.concat(
                      Object.keys(expressions.compile(ngcl)())
                    );
                  }
                  let datang = html(el).attr('data-ng-class');
                  if (datang) {
                    datang = datang.replace('::', '');
                    cls = cls.concat(
                      Object.keys(expressions.compile(datang)())
                    );
                  }
                  cls.forEach((cl) => {
                    html(el).addClass(cl);
                  });
                });
                return Promise.resolve();
github komachi / usedcss / src / index.js View on Github external
html('[ng-class], [data-ng-class]').each((i, el) => {
                  let cls = [];
                  let ngcl = html(el).attr('ng-class');
                  if (ngcl) {
                    ngcl = ngcl.replace('::','');
                    cls = cls.concat(
                      Object.keys(expressions.compile(ngcl)())
                    );
                  }
                  let datang = html(el).attr('data-ng-class');
                  if (datang) {
                    datang = datang.replace('::', '');
                    cls = cls.concat(
                      Object.keys(expressions.compile(datang)())
                    );
                  }
                  cls.forEach((cl) => {
                    html(el).addClass(cl);
                  });
                });
                return Promise.resolve();
github smclab / power-templates / lib / index.js View on Github external
PowerTemplate.prototype.getValue = function (value) {
  var regexp = module.exports.BINDINGS_RE;
  var type = typeof value;
  var match = null;

  if (type === 'function') {
    return value;
  }
  else if ((type === 'string') && (match = value.match(regexp))) {
    return expressions.compile(match[ 1 ]);
  }
  else {
    return value;
  }
};
github Reportr / dashboard / lib / models / alert.js View on Github external
alertSchema.methods.validCondition = function(scope) {
    var expr = expressions.compile(this.condition);
    return expr(scope);
};

angular-expressions

Angular expressions as standalone module

Unlicense
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis

Popular angular-expressions functions