我需要保留一个输入type="text",但会在Android和iOS设备上打开数字键盘.
这是因为输入字段仍然具有诸如的字符,£并且,在一个type="number"或多个字段内是不可能的type="tel".
我发现你可以强制使用iOS上的数字键盘pattern="\d*",但这对Android没有任何作用.
这是我到目前为止:
<input type="text" inputmode="numeric" pattern="\d*" value="£2,000,000" />
Run Code Online (Sandbox Code Playgroud)
我正在尝试从php文件中获取json数据以在Angular控制器中使用.我json_encode(pg_fetch_assoc($result));在php文件中回显,当我console.log($scope.contents);在角度控制器中它带回了json数据,但当我尝试做一个时它回来了ng-repeat
controllers.js:
myApp.controller('ContentCtrl', function ($scope, $http) {
$http({method: 'GET', url: 'content.php'}).success(function(data) {
$scope.contents = data;
});
});
Run Code Online (Sandbox Code Playgroud)
content.php:
<?php
require_once("sdb.php");
$result = pg_query($dbconn, "SELECT * FROM content ORDER BY name ASC");
echo json_encode(pg_fetch_assoc($result));
Run Code Online (Sandbox Code Playgroud)
index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body ng-app="myApp">
<div ng-controller="ContentCtrl">
<ul>
<li ng-repeat="content in contents">
<a href="#">{{content.name}}</a>
</li>
</ul>
</div>
</body>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/controllers.js"></script>
</html>
Run Code Online (Sandbox Code Playgroud) 在请求中使用Angular Material的Progress循环组件的最佳方法是什么$http?
我目前的代码如下:
进度通告:
<md-progress-circular ng-if="determinateValue === 100" md-mode="determinate" value="{{determinateValue}}"></md-progress-circular>
Run Code Online (Sandbox Code Playgroud)
$http 请求:
$scope.determinateValue = 0;
$http.get("/posts")
.success(function (data) {
$scope.posts = data;
$scope.determinateValue = 100;
})
Run Code Online (Sandbox Code Playgroud) 我正在尝试将模块导入typescript文件,然后与Rollup.js捆绑.
但我收到一条错误消息,阻止Rollup完成.
进口:
import * as mapboxgl from 'mapbox-gl';
(mapboxgl as any).accessToken = this.accessToken;
this.map = new mapbox.Map({...});
Run Code Online (Sandbox Code Playgroud)
当我运行tsc时没有任何错误消息,但是当我运行时:
$ rollup -c rollup.config.js
Illegal reassignment to import 'mapboxgl'
Error: Illegal reassignment to import 'mapboxgl'
at error (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\utils\error.js:2:14)
at disallowIllegalReassignment (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\shared\disallowIllegalReassignment.js:9:4)
at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\AssignmentExpression.js:12:3)
at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34
at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5)
at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:8)
at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\BlockStatement.js:8:9)
at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\FunctionExpression.js:7:13)
at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34
at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5)
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
Run Code Online (Sandbox Code Playgroud)
我已经缩小了错误,只有在出现时才会发生(mapboxgl as any).accessToken = this.accessToken;.
我 …
我正在尝试使用Sails.js将我的应用程序投入生产,但无法通过繁琐的任务.这是我收到的错误:
error: Error: The hook `grunt` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or else set
`sails.config.grunt._hookTimeout to a higher value (currently 20000)
at tooLong [as _onTimeout]
(/usr/local/lib/node_modules/sails/lib/app/private/loadHooks.js:92:21)
at Timer.listOnTimeout (timers.js:110:15)
Run Code Online (Sandbox Code Playgroud)
我已经sails.config.grunt._hookTimeout大大增加了,但这个过程还没有完成.运行sails debug在生产或开发输出:
Grunt :: Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Agent.Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Agent.Server.listen (net.js:1267:5)
at Object.start (_debugger_agent.js:20:9)
at startup (node.js:86:9)
at node.js:814:3
Run Code Online (Sandbox Code Playgroud)
我觉得很奇怪,在开发模式下一切正常,但在生产中并非如此.包含的文件非常大,例如角度,力矩和其他模块.这是jsFilesToInject看起来如何:
var jsFilesToInject = [
// Load sails.io before …Run Code Online (Sandbox Code Playgroud) 如何获取用户选择的多个元素document.getSelection()?
document.getElementById("hello").onclick = function() {
selection = document.getSelection();
if(selection) {
console.log(selection.anchorNode.textContent);
}
};
Run Code Online (Sandbox Code Playgroud)
http://jsbin.com/qisawudofa/edit?html,js,控制台,输出
它似乎只返回首先选择的元素,但就我而言,我需要获取所有元素。
或者,有没有办法至少知道何时选择了多个元素?
我希望以$index字母格式输出而不是编号.
<div ng-repeat="name in names">{{$index}}</div>
这可能吗?
我正在使用 Ubuntu 14.04 服务器,并尝试使用以下命令安装 grunt 和 grunt-cli:
npm install -g grunt grunt-cli
Run Code Online (Sandbox Code Playgroud)
一切看起来都很好,没有收到任何错误。但是当我运行标准 grunt 命令时,我收到此错误:
module.js:338
throw err;
^
Error: Cannot find module 'eventemitter2'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/var/www/html/unsplit/node_modules/grunt/lib/grunt/event.js:13:21)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at gRequire (/var/www/html/unsplit/node_modules/grunt/lib/grunt.js:23:24)
at Object.<anonymous> (/var/www/html/unsplit/node_modules/grunt/lib/grunt.js:35:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require …Run Code Online (Sandbox Code Playgroud) 我想开始一个新的Angular 2项目.
我找到了angular2-seed和angular-cli来开始一个新项目,但我想知道使用哪一个以及它们的优点和缺点是什么?
通过以下使用的示例angular.element,如何在每次点击时滚动到ng-repeat中的下一个项目?
这是我到目前为止,我只是不知道接下来该做什么:
var app = angular.module('myApp', []);
app.controller('MainController', ['$scope', function ($scope) {
$scope.items = [{
name: "apple"
}, {
name: "pear"
}, {
name: "Avacado"
}, {
name: "Banana"
}];
$scope.go = function ($event) {
console.log(angular.element($event.currentTarget).parent().next());
};
}]);
Run Code Online (Sandbox Code Playgroud)
HTML:
<div ng-app="myApp">
<div ng-controller="MainController">
<div class="box" ng-repeat="item in items track by $index">
<h3>{{item.name}}</h3>
<button ng-click="go($event)">go to next box</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/0bwcLfv4/2/
jQuery已经包含在网站上,所以我当然希望每个卷轴都有动画.