--------------------JS Interface--------------------------------
Find a company customer
$scope. A = [];
Datacenter.find ("Customer/info", {company:1})
Datacenter.addeventlistener ("Customers", function (e) {
$scope. A = E.data;
$scope. $apply ();
});
if ($ (' #C ')! = null) {
$ (' #C '). Typeahead ({source:
function () {
Return $scope. A
}
});
}
--------------------back-end controller--------------------------------
@RequestMapping (value = "/info", method = Requestmethod.get)
Public Object require (@RequestParam (required = false) Map m) {
Return Dataevent.wrap ("Customers", Customerservice.require (m));
}
Service---Public string[] require (map<string, string> m);
[Email protected]
Public string[] Require (map<string, string> m) {
List List = Customerdao.require (M);
int size = List.size ();
if (size <= 0) {
return new string[]{};
}
ArrayList al = new ArrayList ();
for (int i = 0; i < size; i++) {
Map C = (map) list.get (i);
String cid = c.get ("CID"). ToString ();
String cname = C.get ("cname") = = null? "": C.get ("CNAME"). ToString ();
Al.add (CID + "/" + CNAME); Customer name fuzzy query with no numbering
Al.add (CNAME);
Al.add (cname+ "/" +cid);
Al.add (CID);
}
String[] s = new string[size];
Return (string[]) Al.toarray (s);
}
DAO----//Fetch company user
Public list<map<string, string>> require (map<string, string> m);
--------------------ORM Mapping File--------------------------------
Mapper--<select id= "require" parametertype= "Java.util.Map" resultmap= "Customers" >
SELECT
<include refid= "Columns"/>
From CUSTOMERS
<where>
Company=#{company, jdbctype=numeric} and Black=0
</where>
--------------------HTML5 Part--------------------------------
<div class= "col-md-7 col-sm-7 control-btm Control-label" style= "text-align:left;" >
<input type= "text" class= "Control-btm input-sm form-control" id= "C" value= "" data-provide= "Typeahead" data-items= " "Ng-model=" NameId "ng-blur=" GetName () "/>
<input type= "hidden" class= "id=" CID "ng-model=" CID "/>
</div>
Typeahead Classic drop-down box hint