I'm using an Angular file for both my create and edit page, but was wondering if there's a way to prevent a user editing the name of a Geo Segment on the /edit page.
geo-region-detail.html:
<nav>
<a href="#">Geo Segments</a> :
</nav>
<h1 class="geo-region-name">{{ geoRegion.name || 'Create Geo Segment' }}</h1>
<form ng-submit="updateOrAddGeoRegion()" id="regionForm">
<div class="row">
<div class="control-group span2">
<label class="control-label label-unstyled font-size-14" for="inputId">Label</label>
<div class="controls">
<input type="text" id="inputId" placeholder="Short name" class="input-small" value="{{ geoRegion.label }}" ng-model="geoRegion.label" required="required">
</div>
</div>
<div class="control-group span4">
<label class="control-label label-unstyled font-size-14" for="inputName">Name</label>
<div class="controls">
<input type="text" id="inputName" placeholder="Region Name" class="input-large" value="{{ geoRegion.name }}" ng-model="geoRegion.name" required="required">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label label-unstyled font-size-14" for="inputAddress">Address</label>
<div class="controls">
<input type="text" id="inputAddress" placeholder="Address" class="input-xlarge" value="{{ geoRegion.address }}" ng-model="geoRegion.address">
<google-map-geocoder></google-map-geocoder>
</div>
</div>
location-edit.js:
$scope.newGeoRegion = true
$scope.geoRegionId = ''
$scope.hours = Hours
console.log('$scope.hours', $scope.hours)
$scope.geoRegion = {
app_id: $scope.app_id
geoRegion_id: '',
latitude: 37.7879938,
longitude: -122.40743739,
name: '',
address: '',
radius: 500,
customer_id: $scope.customer_id,
active_daily_clear: false
}
geoRegion_idis filled in, that you're editing, otherwise you're creating? If so, add an attribute to your name textbox likeng-disabled="geoRegion.geoRegion_id". Also, is there any reason you are setting thevalueattributes for the textboxes?ng-modelshould handle that for you<label class="control-label label-unstyled font-size-14" for="inputName">Name</label> <div class="controls"> <input type="text" id="inputName" placeholder="Region Name" class="input-large" ng-disabled="geoRegion.geoRegion_id" value="{{ geoRegion.name }}" ng-model="geoRegion.name" required="required"> </div>geoRegion_idproperty has a value). Change thegeoRegion_idproperty to an empty string, click the "Run" button at the top, and then notice how the textbox is editable.