2014-02-10 22 views

回答

3

您遇到了有关作用域属性原型继承的问题。请看看:What are the nuances of scope prototypal/prototypical inheritance in AngularJS?

你可以,如果你在你的控制器使用对象避免这些问题:

$scope.obj = {}; 
$scope.obj.name = name; 
在你的HTML

你需要写:

<input ng-model="obj.name" > 

现在你可能会在您的ok功能中访问该名称:

$scope.ok = function() { 
    console.log($scope.obj.name) 
    $modalInstance.close($scope.selected.item); 
}; 

你的工作plunkr:http://plnkr.co/edit/PRckScjJQZVdVhXDqjMu?p=preview