an example with $http backend

fix-space-nbsp
Dmitri Akatov 11 years ago
parent 330417ed10
commit 1951e85654

@ -1,24 +1,34 @@
basePath = '..'
files =
[ ANGULAR_SCENARIO
, ANGULAR_SCENARIO_ADAPTER
, 'src/**/*.coffee'
, 'test/e2e/**/*.coffee'
, { pattern: 'examples/simple.html'
, watched: false
, included: false
, served: true }
, { pattern: 'components/angular/angular.js'
, watched: false
, included: false
, served: true }
, { pattern: 'dist/radians.js'
, watched: false
, included: false
, served: true }
toServe = [
'components/angular/angular.js'
'components/angular-bootstrap/ui-bootstrap.js'
'components/angular-bootstrap/ui-bootstrap-tpls.js'
'dist/radians.js'
'examples/simple.html'
'examples/typeahead1.html'
'examples/typeahead2.html'
'examples/typeahead3.html'
'examples/states.json'
'examples/img/ru.gif'
'examples/img/gb.gif'
'examples/img/us.gif'
]
toServe =
for file in toServe
pattern: file
watched: false
included: false
served: true
files = [
ANGULAR_SCENARIO
ANGULAR_SCENARIO_ADAPTER
'src/**/*.coffee'
'test/e2e/**/*.coffee'
].concat toServe
exclude = []
reporters = ['progress']

@ -0,0 +1,3 @@
[ "Russia <img src=\"img/ru.gif\">"
, "USA <img src=\"img/us.gif\">"
, "UK <img src=\"img/gb.gif\">"]

@ -13,13 +13,10 @@ angular.module('typeahead', ['ui.bootstrap', 'radians'])
.controller('TypeaheadCtrl', function ($scope) {
$scope.selected = undefined
$scope.states =
[ 'Russia <img src="img/ru.gif">'
, 'USA <img src="img/us.gif">'
, 'UK <img src="img/gb.gif">'
]
$scope.noimg = function(str) {
return str.replace(/<img[^>]*>/, '')
}
[ 'Russia <img src="img/ru.gif">'
, 'USA <img src="img/us.gif">'
, 'UK <img src="img/gb.gif">'
]
})
</script>
</head>
@ -28,7 +25,6 @@ angular.module('typeahead', ['ui.bootstrap', 'radians'])
<pre>Model: {{ selected | json }}</pre>
<div ng-model="selected" typeahead="state for state in states | ignoreImgFilter:$viewValue" contenteditable>
</div>
<!-- <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue"> -->
</div>
</body>
</html>

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en" ng-app="typeahead">
<head>
<meta charset="utf-8">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="../components/angular/angular.js"></script>
<script src="../components/angular-bootstrap/ui-bootstrap.js"></script>
<script src="../components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="../dist/radians.js"></script>
<script>
angular.module('typeahead', ['ui.bootstrap', 'radians'])
.controller('TypeaheadCtrl', function ($scope, $http) {
$scope.selected = undefined
$scope.states = function(query){
return $http.get("states.json").then(function(response){
console.log("response", response)
return response.data
})
}
})
</script>
</head>
<body>
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{ selected | json }}</pre>
<div ng-model="selected" typeahead="state for state in states($viewValue)" contenteditable>
</div>
</div>
</body>
</html>