jeudi 23 avril 2015

Is it bad practice to use id for if/else conditions?

I have question on if/else condition , my database has saved region id 5657 that i am using to implement if/else conditions.

1- is it bad practice to use id ?

2- what is right way to implement if/else condition in this case ?

ctrl.js

if( geoLocation.items ) {
    $.each(geoLocation.parent(), function( index, location ) {
        if( location.id === 5657 ) {
            var disableItemId = 'disabled' + location.id;
            // Get the model
            var model = $parse( disableItemId );
            // Assigns a value to it
            model.assign( $scope, false );
        }
    });
    $.each( geoLocation.items, function( index, location ) {
        var disableItemId = 'disabled' + location.id;
        // Get the model
        var model = $parse( disableItemId );
        // Assigns a value to it
        model.assign( $scope, false );
    });
}

Aucun commentaire:

Enregistrer un commentaire