jongio / angularjs-webapi-ef Goto Github PK
View Code? Open in Web Editor NEWAngularJS CRUD Grid with WebApi, EF, Bootstrap, Font Awesome & Toastr
Home Page: http://blog.jongallant.com/p/angularjs-crud-grid-index.html
License: MIT License
AngularJS CRUD Grid with WebApi, EF, Bootstrap, Font Awesome & Toastr
Home Page: http://blog.jongallant.com/p/angularjs-crud-grid-index.html
License: MIT License
In crud-grid-directive.js, I was having a really hard time getting my lookups to work. It seems that c is getting out of scope in the loop in $scope.setLookupData. I kept getting errors because c.lookup was undefined. I tried putting everything in the loop in a closure like so:
$scope.setLookupData = function () {
for (var i = 0; i < $scope.columns.length; i++) {
(function (i) {
var c = $scope.columns[i];
if (c.lookup && !$scope.hasLookupData(c.lookup.table)) {
var res = crudGridDataFactory(c.lookup.table).query();
res.$promise
.then(function (data) {
$scope.setIndividualLookupData(c.lookup.table, data); // c out of scope here?
})
.catch(function (data) {
console.log("Error: ", data);
});
}
})(i);
}
};
Now it works perfectly. There are some other changes to how the promise is used that you may ignore or include at your discretion - I ended up making them while trying to debug the problem and thought they were good enough to keep in.
The closure idea came from StackOverflow:
http://stackoverflow.com/questions/17244614/promise-in-a-loop
Hope this is useful.
-k
This lets you use any naming convention for your PKs.
$scope.deleteObject = function (object) {
var pkField = $attrs.pkField;
crudGridDataFactory($attrs.table).delete({ id: object[pkField] }, successCallback, errorCallback);
};
$scope.updateObject = function (object) {
var pkField = $attrs.pkField;
crudGridDataFactory($attrs.table).update({ id: object[pkField] }, object, successCallback, errorCallback);
};
Can't seem to find the @Styles.Render("/content/bootstrap/base") or @Scripts.Render("/bundles/bootstrap") defined in BundleConfig.cs
it will be nice if the pagination branch worked ? any idea ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.