我的Chrome控制台出错,似乎无法解决。
我有一个控制器和前端代码。想法是我有两个下降,第二个依赖于第一个。他们从父对象和子对象中获取数据,第二个框显示第一个子框。
它工作了几个星期,但我今天早上仔细检查了一些功能,它似乎被打破了,我收到了错误。
任何人都可以看到错误的代码吗?
**错误 TypeError:无法在字符串'Post Data Gets Submitted Successfully'上创建属性'ProductType' at Object.fn.assign(eval at compile(angular.js:15500),:4:431) at Object。$$ writeModelToScope(angular.js:29101) 在angular.js:29095 在g(angular.js:29014) 在e(angular.js:28997) at Object。$$ runValidators(angular.js:28941) at Object。$$ parseAndValidate(angular.js:29082) at Object。$ commitViewValue(angular.js:29048) at Object。$$ debounceViewValueCommit(angular.js:29186) at Object。$ setViewValue(angular.js:29166)
controller.js
FirstModule.controller('dropDown', function ($scope) {
console.log("First cnt dropDown LOADED");
$scope.productsandformats = [
{
"name": "tom",
"format": [
{"Fname": "ddf", "id": "Roadside"},
{"Fname": "ffr", "id": "roadsoop"},
{"Fname": "Wfg(Digital)", "id": "fff"}
]
},
{
"name": "harry",
"format": [
{"Fname": "fef", "id": "4ee"},
{"Fname": "fff (Digital)", "id": "derfere"}
]
},
{
"name": "Supermarkets",
"format": [
{"Fname": "Asda ", "id": "asda"},
{"Fname": "Sainsbury’s ", "id": "sains"}
]
}];
$scope.productTypeChange = function () {
$scope.formats = $scope.productsandformats.find(ps => ps.name === $scope.formData.ProductType.name
)
//NG-Change
$scope.myFunc = function () {
var jsonItem = ($scope.formData.formatType.id);
sessionStorage.setItem('format', jsonItem);
}
} });
前端角度
<div class="form-group">
<div ng-controller="dropDown">
<select ng-model="formData.ProductType.name" ng-change="productTypeChange()" ng-options="product.name as product.name for product in productsandformats">
<option value="">- Please Choose -</option>
</select>
<select ng-model="formData.formatType" ng-options="format.Fname for format in formats.format" ng-if="formData.ProductType.name" ng-change="myFunc()">
<option value="">- Please Choose -</option>
</select>
<div class="row">
<div class="btn-group creative-format">
<label class="btn btn-primary" ng-model="format" uib-btn-radio="'Roadside'">Roadside</label>
<label class="btn btn-primary" ng-model="format" uib-btn-radio="'Digital'">Digital</label>
<label class="btn btn-primary" ng-model="format" uib-btn-radio="'Billboard'">Billboard</label>
<label class="btn btn-primary" ng-model="format" uib-btn-radio="'Premium'">Premium</label>
</div>
</div>
<!--<div ng-controller="dropDown">-->
<!--<button ng-click="myFunc()">send session</button>-->
<!--</div>-->
<!--<script>var jsonItem = JSON.stringify($scope.formData.ProductType.name);-->
<!--sessionStorage.setItem('format', jsonItem);</script>-->
</div>
</div>