I'm working with Angular version 1.2.2 for the first time and trying to make a simple directive that uses isolate scope with '=' binding to pass in an object. I've done this a few times before so I'm wondering if maybe there was a change in 1.2.2 that changed this?
Here is my directive:
.directive('vendorSelector', function (VendorFactory) { return { restrict: 'E', replace: true, scope: { vendorId: '=' }, template: '<select ng-model="vendorId" ng-options="id for id in vendorIds">' + '<option value="">-- choose vendor --</option>' + '</select>', link: function (scope, element, attrs) { VendorFactory.getVendorIds().then(function(result) { scope.vendorIds = result; }); } } }) My HTML template using the directive is as follows:
<div class="padding"> <vendor-selector vendorId="someValue"></vendor-selector> {{ someValue }} </div> And the backing controller:
.controller('AddProductController', function($scope, ProductFactory, AlertFactory) { $scope.vendorId = 0; $scope.someValue = undefined; }) I've tried using both $scope.someValue and $scope.vendorId as the supplied object in the html template. In both cases the error I'm getting back is Expression 'undefined' used with directive 'vendorSelector' is non-assignable!. Am I missing something obvious that is preventing these values from being 2-way bound in the isolate scope?