我正在使用angularjs处理autocomplete指令但有一些问题.
我有一个具有自动完成输入的表单.当我在那里输入内容时,术语变量将作为JSON发送:

但是,当我使用相同的功能(来自不同的角度控制器,但相同的功能)在另一种形式时,术语变量发送完美,自动完成工作正常:

这是我的角度函数:
$scope.getCustomers = function (searchString) {
return $http.post("/customer/data/autocomplete",
{term: searchString})
.then(function (response) {
return response;
});
};
Run Code Online (Sandbox Code Playgroud)
你觉得怎么了?
我试图console.log()从这个$范围做一个简单的事情:
<div ng-controller="CustomerController" id="customer-block">
<h3>Customer Information</h3>
<div class="col-md-4">
<label>Address 1:</label>
<input type="text" ng-model="customer.address1" class="form-content"
id="customer-address1" />
</div>
<div class="col-md-4">
<label>Address 2:</label>
<input type="text" ng-model="customer.address2" class="form-content"
id="customer-address2" />
</div>
<div class="col-md-4">
<label>City</label>
<input type="text" ng-model="customer.city" class="form-content"
id="customer-city" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的javascript文件:
lima3app.controller("CustomerController", function($scope){
console.log($scope.customer);
});
Run Code Online (Sandbox Code Playgroud)
但日志返回我未定义.这有什么问题?
这是傻瓜:http://plnkr.co/edit/MU2i46o03bs22Jwh6QIe
我在iframe中调用了一个jQueryUI对话框,如下所示:

但我需要iframe之外的对话框(喜欢window.parent ----> open dialog或类似的东西).
我正在设置我的.htaccess文件以使用友好的网址(手动).但是,当我转到网址时,服务器显示错误404.
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
Rewriterule ^register$ register.php
Run Code Online (Sandbox Code Playgroud)
我确定mod_rewrite已启用,因为我在使用时看到了它phpinfo().
我使用angular bootstrap ui(typeahead)尝试在输入聚焦时显示我的客户列表,其中:
lima3app.directive('typeaheadOpenOnFocus', function() {
return {
require: ['ngModel'],
link: function(scope, element, attr, ctrls) {
element.bind('focus', function() {
ctrls.$setViewValue('');
console.log('customer.customer');
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
所以在视图中我设置了我的输入:
<input type="text" class="form-content req" id="form-customer"
name="formcustomer"
typeahead="customer as customer.customer for customer in customerList | filter:{customer:$viewValue}"
typeahead-on-select="onCustomerSelect($item)"
typeahead-append-to-body="true"
typeahead-open-on-focus
ng-model="customer.customer"
focus="true"
required="required">
Run Code Online (Sandbox Code Playgroud)
但代码,不起作用.有没有办法做到这一点?
我是Android的新手.我正在尝试设置一个简单的TabHost视图.
这是我的xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@+id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#160203" />
<FrameLayout
android:id="@+id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的java代码:
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
public class Tabhost extends FragmentActivity {
private FragmentTabHost tabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tabhost);
tabHost = (FragmentTabHost) findViewById(R.id.tabhost);
tabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Articulos"),
ArticulosFragment.class, null);
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Tutoriales"),
TutorialesFragment.class, null);
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Cursos"),
CursosFragment.class, null);
}
}
Run Code Online (Sandbox Code Playgroud)
但该应用程序崩溃与此错误消息(我真的不知道这意味着):

你觉得怎么回事?
我正在考虑如何通过具有相同值的对象对数组进行分组.
我从MySQL查询得到这个结果:
Date StartTime EndTime
2014-12-01 08:00 12:00
2014-12-01 10:00 16:00
2014-12-02 12:00 18:00
2014-12-03 10:00 20:00
Run Code Online (Sandbox Code Playgroud)
我把这个数据放在一个名为的PHP变量中$Data.
有可能用php获取这样的json数组:?
[
{
"2014-12-01": [
{
"StartTime": "08:00",
"EndTime": "12:00"
},
{
"StartTime": "10:00",
"EndTime": "16:00"
}
]
},
{
"2014-12-02": [
{
"StartTime": "12:00",
"EndTime": "18:00"
}
]
},
{
"2014-12-03": [
{
"StartTime": "10:00",
"EndTime": "20:00"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
如果我使用echo json_encode($Data),结果是:
[
{
"Date": "2014-12-01",
"StartTime": "10:00",
"EndTime": "16:00"
},
{
"Date": "2014-12-02",
"StartTime": "12:00", …Run Code Online (Sandbox Code Playgroud) 我正在尝试将带有零的数字(cuz是表单数据库)传递给javascript函数:
<table>
<tr onClick="View(<?php echo $id; ?>)">
<td> <?php echo $id; ?> </td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
Javascript功能:
function View(id){
alert(id);
}
Run Code Online (Sandbox Code Playgroud)
例如:如果我的身份是0005警报5.如果我的身份是0006警报6.
我需要提醒' 0005' - ' 0006'但我无法解决这个问题.
谢谢你的回答
我将这个字符串(来自网络服务)放入这样的 JSONArray 中,
[
{
"lat": "-16.408545",
"lon": "-71.539105",
"type": "0",
"distance": "0.54"
},
{
"lat": "-16.4244317845",
"lon": "-71.52562186",
"type": "1",
"distance": "1.87"
},
{
"lat": "-16.4244317845",
"lon": "-71.52562186",
"type": "1",
"distance": "0.22"
}
]
Run Code Online (Sandbox Code Playgroud)
我需要按距离键对其进行排序以显示最近的第一个和最远的最后一个。我没有尝试任何代码,因为我真的没有任何想法。我没有使用 GSON 库,我使用的是org.json.JSONArray.
我试图停止return语法:
<script>
$(document).ready(function() {
setInterval(function() {
var url = "../view/anychange.php";
$.getJSON(url, function(data) {
f(data.exists == 0){
alert("0");
} else {
alert("1");
return;
}
});
}, 5000);
});
</script>
Run Code Online (Sandbox Code Playgroud)
该函数每 5 秒验证一次表中是否存在数据。
我需要在data.exists == 1( alert("1"))时停止该功能。
我有两个变量(我从数据库中获取):
$start = '07:14:10';
$end = '07:14:58';
Run Code Online (Sandbox Code Playgroud)
我需要区分它们.
我想答案可能是00:00:48.