i work angular , try disable button if value scope 'true'. saw ng-disabled seems perfect don't know why doesn't work...
here html:
<div ng-controller="myctrl"> <h4>{{ building.isbuildable }}</h4> <button ng-click='build(building.id)' class="btn btn-primary" ng-disabled="!build.isbuildable"> build </button> </div> and angular:
var myapp = angular.module('myapp',[]); myapp.factory('colony', function () { 'use strict'; return { isbuildable: function () { return true; //return false; } }; }); myapp.controller('myctrl', ['$scope', 'colony', function ($scope, colony) { 'use strict'; var building = { name: 'building name', isbuildable: null }; $scope.building = building; $scope.building.isbuildable = colony.isbuildable(); $scope.build = function (id) { }; }]); http://jsfiddle.net/xz7arl0s/1/
as can see in jsfiddle, it's disabled when isbuildable true. missing here?
you have typo, you're referring build instead of building in ng-disabled binding.
update code to:
<div ng-controller="myctrl"> <h4>{{ building.isbuildable }}</h4> <button ng-click='build(building.id)' class="btn btn-primary" ng-disabled="!building.isbuildable"> build </button> </div> i edited on fiddle.
Comments
Post a Comment