Choosing multiple outputs in Angular

I have an error in my Chrome console that I cannot solve.

I have a controller and front end code. The idea is that I have two pulls, the second depends on the first. they get data from objects that have a parent and a child, the second window shows the first fields for the children.

Its been working for weeks, but today I double check the functionality and it seems like it is broken and I am getting below error.

can anyone see what is wrong with the code?

** ErrorTypeError: Unable to create property "ProductType" on line "Published data was successful!" in Object.fn.assign (eval at compile (angular.js: 15500) ,: 4: 431) in Object. $$ writeModelToScope (angular.js: 29101) with angular.js: 29095 with g (angular.js: 29014) with e (angular.js: 28997) in Object. $$ runValidators (angular.js: 28941) to Object. $$ parseAndValidate (angular.js: 29082) to Object. $ commitViewValue (angular.js: 29048) to Object. $$ debounceViewValueCommit (angular.js: 29186) to 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);
        }
    } });

      

Angular front end

<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>

      

+3


source to share





All Articles