Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ac-options and ac-model attributes must be set #14

Open
texas697 opened this issue Oct 22, 2014 · 9 comments
Open

ac-options and ac-model attributes must be set #14

texas697 opened this issue Oct 22, 2014 · 9 comments

Comments

@texas697
Copy link

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);
});

@john-oc
Copy link
Owner

john-oc commented Oct 22, 2014

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.

@texas697
Copy link
Author

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

@john-oc
Copy link
Owner

john-oc commented Oct 22, 2014

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
#14 (comment).

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

@texas697
Copy link
Author

thank you!

@john-oc
Copy link
Owner

john-oc commented Oct 27, 2014

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

@ramana4029
Copy link

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

@john-oc
Copy link
Owner

john-oc commented Nov 25, 2014

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.

@mistermark
Copy link

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;
});

@john-oc
Copy link
Owner

john-oc commented Jun 8, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants