This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
element.bind('blur', function () { //some third party component directive | |
scope.$apply(function(){ | |
$scope.model='someData'; //scope updates have to be done inside the $apply callback | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The incorrect way | |
var employees=$resource('url').query(); //this is async call. Return value of the call is a empty array [] | |
console.log(employees.length); //This is immediately executed so length is 0. Data gets filled in future. | |
//Right way | |
$resource('url').query().then(function(data) { | |
employees = data; | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$http({method: 'GET', url: '/someUrl'}) | |
.success(function(data) { | |
$scope.foo = data; | |
}); | |
<!--In HTML--> | |
<p>{{foo}}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.foo = $http({method: 'GET', url: '/someUrl'}); | |
<!--In HTML this works--> | |
<div>{{foo}}</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<location path="signin-google"> | |
<system.web> | |
<authorization> | |
<allow users="*" /> | |
</authorization> | |
</system.web> | |
</location> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.directive('myDirective', function () { | |
return { | |
restrict: 'E', | |
scope: { | |
model: '=' | |
}, | |
// The linking function will add behavior to the template | |
link: function (scope, element, attrs) { | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id='userData'> | |
<div id='sectionParticulars' ng-include="'particularsTemplate'" ng-init='model=model'></div> | |
<div id='sectionAddress' ng-include="'addressTemplate'" ng-init='model=model.address'></div> | |
<div id='sectionDepedents' ng-include="'dependentTemplate'" ng-init='model=model.dependents'></div> | |
</div> | |
<script type="text/ng-template" class="template" id="particularsTemplate"> | |
<!-- HTML related to user particulars--> | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SomeCtrl($scope) { | |
$scope.countries = ['can', 'usa', 'fra', 'jap']; | |
$scope.user = {name: "Evil Trout"}; | |
$scope.age = 34; | |
// Our template now can render {{age}}, {{user.name}} and a list of countries! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutofacBootstrap | |
{ | |
internal static void Init(ContainerBuilder builder) | |
{ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void RegisterIOC() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterControllers(typeof(MvcApplication).Assembly); | |
builder.RegisterApiControllers(typeof(MvcApplication).Assembly); | |
AutofacBootstrap.Init(builder); | |
var container = builder.Build(); | |
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); | |
GlobalConfiguration.Configuration.DependencyResolver = new Autofac.Integration.WebApi.AutofacWebApiDependencyResolver(container); | |
} |