What is working: The ng-options
contains all names and it is shown in the dropdown-list.
Problem:
"Error: [$compile:nonassign] Expression 'undefined' used with directive 'fileWidget' is non-assignable!" occured.
GeometryService.js
angular.module('COMLEAMclient')
.factory('GeometryService', function($resource) {
var selectedGeometry = {name:'Select name...'};
}
FileWidgetDirective.js
angular.module('COMLEAMclient')
.directive('fileWidget', ['$log', '$parse', function($log, $parse) {
return {
scope: {
data: '=',
selectedFile: '=',
updateSelection: '&',
selected: '=',
onReadFile: '&',
},
....
}
)
}
InputController.js
<div file-widget data="iCtrl.geometryFiles" update-selection= "iCtrl.setSelectedGeometry(name)" selectedFile= "iCtrl.selectedGeometryFile" on-read-file="iCtrl.saveGeometryFiles(file,name)"></div>
FileWidget.html
<select class="form-control"
ng-options="elem.name for elem in data"
ng-model="selectedFile"
ng-change="onSelectionChange()">
</select>
Any ideas?
In order to have Select name...
you need to have an option
element:
<select class="form-control"
ng-options="elem.name for elem in data"
ng-model="selectedFile"
ng-change="onSelectionChange()">
<option value="">Select name...</option>
</select>
You are trying to assign to an object, and that is non assignable, which is why you're getting the non-assignable
error. You need to have a variable that can contain the value the selected option, try:
ng-model="selectedFile.name"