0

I have a developing an app using angularJS + Symfony. From backend I have the following entities:

class Property {...}

class Land extends Property {...}

class House extends Property {...}

class Office extends Property {...}

class Field extends Property {...}

Each subclass has its own specific fields.

From frontend I need to create any subclass of property in one screen. So I would show/hidden serveral fields by the property type selected. I read about ng-show but I would like some more dynamic and general due to I will have the same problem with the "view" screen.

What do you suggest? What is the best approach?

1 Answer 1

1

I would use angular ui-router. This will allow you to create different states that show the different classes without your html becoming large and cumbersome.

For Example:

myApp.config(function($stateProvider, $urlRouterProvider) {
   //
   // For any unmatched url, redirect to /state1
   $urlRouterProvider.otherwise("/state1");
   //
   // Now set up the states
   $stateProvider
     .state('Property', {
      url: "/Property",
     templateUrl: "partials/property.html"
    })
    .state('Property.land', {
      url: "/land",
      templateUrl: "partials/property.land.html",
      controller: function($scope) {
        $scope.items = ["A", "List", "Of", "Items"];
      }
    })
});
Sign up to request clarification or add additional context in comments.

2 Comments

Sounds good solutions. How can I show the correct partial by the selected option from combobox? Or in other words... How can I change the state by the selected option from combobox?
If you attach a $state.go('toState', result); to each of the options in the combobox it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.