what i wanted to do sounds pretty simple but, the result i got is awkward for me. there is a view with a text filed:
<input colorpicker="hex" type="text" ng-model="item.bgcolor" style="background:{{item.bgcolor}}"/>
In the controller i want to bind the value of the text field and concatenate with string variable like this :
var page = 'hello' + $scope.item.bgcolor + 'world';
the result is hello undefined world
but if i did console.log($scope.item.bgcolor);
i get the text field value in the console.
the controller code:
.controller('mainCtrl', function($scope) {
$scope.item = {
bgcolor: $scope.bgcolor,
};
var page = 'hello' + $scope.item.bgcolor + 'world';
$scope.show = function() {
console.log('page', page);
console.log('bgcolor', $scope.item.bgcolor);
};
})
the main view code:
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<label>Background color</label>
<input colorpicker="hex" type="text" ng-model="item.bgcolor" style="background:{{item.bgcolor}}"/>
<label>Header color</label>
<input colorpicker="hex" type="text" ng-model="item.headercolor" style="background:{{item.headercolor}}"/>
</div>
</div>
app.js:
.state('app.main', {
url: '/main',
views: {
'menuContent': {
templateUrl: 'views/main.html',
controller: 'mainCtrl'
}
}
})