acute-select icon indicating copy to clipboard operation
acute-select copied to clipboard

ac-options and ac-model attributes must be set

Open texas697 opened this issue 11 years ago • 9 comments

I am trying to get this working with my project but I am having trouble. I have copied and pasted your example code into my project and I am getting this error.

ac-options and ac-model attributes must be set

I would like to use this, currently I am using Angular-Ui typeahead directive. This is how I am using it. If you could show me how to transition I would be grateful. thank you

Here is where I am getting the jobArray //GET Jobs $scope.jobArray = {}; JobGet.query().then(function (data) { $scope.jobArray = data; }, function (reason) { errorMngrSvc.handleError(reason); });

texas697 avatar Oct 22 '14 11:10 texas697

What have you set the ac-model attribute to? Have you defined it on the scope? It needs to be initialised either to null or one of the items in the job array.

john-oc avatar Oct 22 '14 21:10 john-oc

here is my post on stackoverflow. if you need more information let me know http://stackoverflow.com/questions/26499224/how-to-setup-angular-acute-select

texas697 avatar Oct 22 '14 21:10 texas697

On 22/10/2014 22:03, texas697 wrote:

here is my post on stackoverflow. if you need more information let me know

— Reply to this email directly or view it on GitHub https://github.com/john-oc/acute-select/issues/14#issuecomment-60154926.

I'll set up a demo on Plunker and post a link to it on GitHub.

john-oc avatar Oct 22 '14 21:10 john-oc

thank you!

texas697 avatar Oct 22 '14 21:10 texas697

Sorry I've not had a chance to get a demo up and running on Plunker yet, but looking at your markup on stackoverflow I see a couple of issues. You have ac-model set as "currentItem.JobItems[0].JobItemName", but I think that will be undefined when acute select initialises. You need a separate scope variable for the model, e.g. $scope.jobItemModel, and set it to null at the top of your controller. Then set it to the first job item when you've got the data from the server.

Also, in ac-options, shouldn't "currentItem.JobItems.JobItemName" be "currentItem.JobItems[0].JobItemName"?

Hope this is of some help.

John

john-oc avatar Oct 27 '14 21:10 john-oc

Hey John, is there an update on this, I am also seeing the same error on the console but select shows up just fine

ramana4029 avatar Nov 25 '14 18:11 ramana4029

If you're getting the message "ac-options and ac-model attributes must be set", even though you've set the attributes, it's most likely because the scope variable pointed to by the ac-model attribute is undefined when ac-select initialises. E.g. if you have ac-model="myModel", try including the line

$scope.myModel = null;

or

$scope.myModel = [some value];

at the start of your controller.

john-oc avatar Nov 25 '14 21:11 john-oc

This helped me getting rid of this error on my project. I was pulling data from a static JSON file and now have it like this:

$scope.listOfCurrencies = null;
$scope.modelCurrency = null;

$http({
    method: "GET",
    url: defaults.dataUrl,
    cache: false
}).success(function(res, err) {
    $scope.listOfCurrencies = res.data;
});

mistermark avatar Feb 24 '15 14:02 mistermark

Hi there,

When I wrote acute select there wasn't an alternative that had the features I needed, and though it worked for my purposes, I now feel it has too many issues for me to recommend using it. There are some good alternatives now. UI Select, in particular, looks very promising, so I'd suggest trying that:- http://angular-ui.github.io/ui-select/

Kind regards,

John

-----Original message----- From: ROJAHEMA [email protected] Date: Tue, 06 Jun 2017 05:43:28 +0100 To: john-oc/acute-select [email protected] Subject: Re: [john-oc/acute-select] ac-options and ac-model attributes must beset (#14)

Hey john,

after declaring also am facing the same issue.. Can you please guide me.

ac-options and ac-model attributes must be set

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/john-oc/acute-select/issues/14#issuecomment-306387782

john-oc avatar Jun 08 '17 16:06 john-oc