阵列工厂使用 AngularJS 的 select-box 中未显示的新项目
New items don't displaing in select-box from array factory use AngularJS
你好,我创建了简单的 AngularJS 应用程序,我有两个按钮(新建 Phone 和 新建类别), 我将我的 类别 保存到数组使用工厂:
myApp.factory('categoriesStorage', function () {
var storage = [];
var categories = ["Apple","HTC"];
storage.addCategory = function (categoryTest) {
categories.push(categoryTest);
console.log(categories);
}
storage.getCategories = function()
{
return categories;
}
return storage;
});
在 添加新的 Phone 表格我有 dx-select-box
-element:
<div class="dx-label">Phone Name</div>
<div dx-select-box="nameOfPhone" ng-model="phoneName"></div><br/><br />
为了从数组中获取元素,我使用 HomeController.js 中的下一个代码
// phone select 弹出框的名称
$scope.nameOfPhone = {
items: categoriesStorage.getCategories()
};
有效
直到我改变焦点或关闭 添加新类别 表单时,新元素添加到数组但不显示到 select-box 。
感谢您的回答!
显示添加phone视图时需要再次调用此行。
$scope.nameOfPhone = {
items: categoriesStorage.getCategories()
};
你好,我创建了简单的 AngularJS 应用程序,我有两个按钮(新建 Phone 和 新建类别), 我将我的 类别 保存到数组使用工厂:
myApp.factory('categoriesStorage', function () {
var storage = [];
var categories = ["Apple","HTC"];
storage.addCategory = function (categoryTest) {
categories.push(categoryTest);
console.log(categories);
}
storage.getCategories = function()
{
return categories;
}
return storage;
});
在 添加新的 Phone 表格我有 dx-select-box
-element:
<div class="dx-label">Phone Name</div>
<div dx-select-box="nameOfPhone" ng-model="phoneName"></div><br/><br />
为了从数组中获取元素,我使用 HomeController.js 中的下一个代码 // phone select 弹出框的名称
$scope.nameOfPhone = {
items: categoriesStorage.getCategories()
};
有效
直到我改变焦点或关闭 添加新类别 表单时,新元素添加到数组但不显示到 select-box 。
感谢您的回答!
显示添加phone视图时需要再次调用此行。
$scope.nameOfPhone = {
items: categoriesStorage.getCategories()
};