我的JS Ctrl:
menuModule.controller('MenuPropertiesCtrl', ['$scope', '$modal', '$location', 'ApplicationService', function ($scope, $modal, $location, ApplicationService) {
var modal;
$scope.propertieRef = '';
$scope.find_applications_by_name_for_diff = function (name) {
console.log($scope.propertieRef);
return ApplicationService.with_name_like(name).then(function (applicationsByName) {
return _(applicationsByName).flatten().map(function (application) {
application.title = application.name + ", " + application.version //Display purposes
if((application.title === $scope.propertieRef))
{
application.title ='';
}
return application;
}).value();
});
};
....
}]);
我的HTML:
<div class="form-group">
<label for="propertiesRefApplication">Version de référence</label>
<input type="text" class="form-control" required ng-trim="true" ng-model="propertieRef"
id="propertiesRefApplication" placeholder="Propertie de référence"
typeahead="application as application.title for application in find_applications_by_name_for_diff($viewValue)"/>
</div>
为什么当我修改输入时,我不会检索$scope.propertieRef
答案 0 :(得分:1)
您需要确保已使用ngApp和ngController指令链接到angular并包装HTML:
我已在此处创建了您应用的缩减版本:http://jsfiddle.net/z0um7ht3/
<div class="form-group" ng-controller="MenuPropertiesCtrl">
<label for="propertiesRefApplication">Version de référence</label>
<input type="text" class="form-control" required ng-model="propertieRef"/>
<span>{{propertieRef}}</span>
</div>
ngApp指令在正文上设置:
<body ng-app="menuModule">
(参见小提琴选项)
Angular Docs:https://docs.angularjs.org/api/ng/directive/ngApp
注意:如果您还没有通过手机猫教程,那值得一试 - https://docs.angularjs.org/tutorial
答案 1 :(得分:0)
我看不到你的所有代码,但要确保你:
1.包含的脚本
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>
声明对ui.bootstrap的依赖
var menuModule = angular.module('menuModule', ['ui.bootstrap']);
请参阅此处的演示